kconfq
[!CAUTION] The project is WIP and is not ready to be used yet! Please wait until the version
v1.0.0.
A portable way to query kernel configuration on a live system (/boot/config-*
or /proc/config.gz).
It provides:
- A CLI (
kconfq) - A C-API library (
libkconfq.so,kconfq.h,kconfq.pc) - A Rust crate
Usage (as a CLI)
Instaling via cargo:
Instaling via Nix:
Running without installation:
Usage as a C-API library
Even though the core of the library is written in Rust, it can be compiled as a
cdynlib with C ABI.
Alongside with libkconfq.so the project will also generate kconfq.h and
kconfq.pc.
All of this makes it possible to use library as any normal C dependency. Here is an example of how this would look like in Meson
kconfq = dependency('kconfq')
Building from source
To build and install library from source you have to use cargo-c.
Using inside the flake.nix
This is how you would add this library to your flake.nix and then reference it
inside your derivation's buildInputs
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
flake-utils.url = "github:numtide/flake-utils";
kconfq = {
url = "github:synalice/kconfq";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, kconfq }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages.default = pkgs.clangStdenv.mkDerivation {
pname = "example";
version = "0.1.0";
src = ./.;
buildInputs = [ kconfq.packages.${system}.libkconfq ];
};
}
);
}
Cross-compilation
The project was created with easy cross-compilation in mind.
Here is how you can cross-compile libkconfq for aarch64-unknown-linux-gnu
using Nix
[!TIP] To cross-compile for different host architectures, replace
aarch64-multiplatformwithriscv64or something else. Read more here.
License
This project is under the MIT license.