A Kconfig parser written in rust.
23
stars
214
commits
Rust
primary language
Sep 1, 2026
updated
Kconfig is a language that describes configuration options for the Linux Kernel. The syntax looks like this:
# https://github.com/torvalds/linux/blob/master/arch/riscv/Kconfig#L771
config EFI
bool "UEFI runtime support"
depends on MMU
default y
select EFI_STUB
help
This option provides support for runtime services provided
by UEFI firmware.
config entry: We define a config named EFI. The next lines are the attributes of this entry.EFI is a boolean config.EFI depends on the config MMU.y.EFI is equals to true then it enables EFI_STUB.help attribute defines a help text for the end user.There are plenty of other keywords in the Kconfig language, check out the official documentation for more details.
Features
source is met, it reads and parses the specified configuration file.clone() a lot. Do not expect amazing performances.glob-wildcard (used by coreboot, for example) and kconfiglib compatibility. Enabling them adds support for some non-standard entries and attributes used by these projects.cargo add nom-kconfig
use nom_kconfig::{parse_kconfig, KconfigInput};
use std::path::PathBuf;
use nom_kconfig::{KconfigFile};
use std::collections::HashMap;
// curl https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.4.9.tar.xz | tar -xJ -C /tmp/
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut variables = HashMap::new();
variables.insert("SRCARCH", "x86");
let linux_dir = PathBuf::from("/tmp/linux-6.4.9");
let kconfig_file = KconfigFile::new_with_vars(
linux_dir.clone(),
linux_dir.join("Kconfig"),
&variables,
&Default::default(),
);
let input = kconfig_file.read_to_string()?;
let kconfig = parse_kconfig(KconfigInput::new_extra(&input, kconfig_file));
println!("{:?}", kconfig);
Ok(())
}
Rust
100.0%
A Kconfig parser written in rust.
23
stars
214
commits
Rust
primary language
Sep 1, 2026
updated
Kconfig is a language that describes configuration options for the Linux Kernel. The syntax looks like this:
# https://github.com/torvalds/linux/blob/master/arch/riscv/Kconfig#L771
config EFI
bool "UEFI runtime support"
depends on MMU
default y
select EFI_STUB
help
This option provides support for runtime services provided
by UEFI firmware.
config entry: We define a config named EFI. The next lines are the attributes of this entry.EFI is a boolean config.EFI depends on the config MMU.y.EFI is equals to true then it enables EFI_STUB.help attribute defines a help text for the end user.There are plenty of other keywords in the Kconfig language, check out the official documentation for more details.
Features
source is met, it reads and parses the specified configuration file.clone() a lot. Do not expect amazing performances.glob-wildcard (used by coreboot, for example) and kconfiglib compatibility. Enabling them adds support for some non-standard entries and attributes used by these projects.cargo add nom-kconfig
use nom_kconfig::{parse_kconfig, KconfigInput};
use std::path::PathBuf;
use nom_kconfig::{KconfigFile};
use std::collections::HashMap;
// curl https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.4.9.tar.xz | tar -xJ -C /tmp/
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut variables = HashMap::new();
variables.insert("SRCARCH", "x86");
let linux_dir = PathBuf::from("/tmp/linux-6.4.9");
let kconfig_file = KconfigFile::new_with_vars(
linux_dir.clone(),
linux_dir.join("Kconfig"),
&variables,
&Default::default(),
);
let input = kconfig_file.read_to_string()?;
let kconfig = parse_kconfig(KconfigInput::new_extra(&input, kconfig_file));
println!("{:?}", kconfig);
Ok(())
}
Rust
100.0%