nixops4/nix-bindings-rust
Use the Nix package manager as a library
{ "createdAt": "2025-10-04T00:09:22Z", "defaultBranch": "main", "description": "Use the Nix package manager as a library", "fullName": "nixops4/nix-bindings-rust", "homepage": null, "language": "Rust", "name": "nix-bindings-rust", "pushedAt": "2025-11-01T02:33:02Z", "stargazersCount": 19, "topics": [], "updatedAt": "2025-11-06T23:16:17Z", "url": "https://github.com/nixops4/nix-bindings-rust"}nix_bindings_* crates
Section titled “nix_bindings_* crates”Use the Nix [C API] from Rust.
Build with nix-cargo-integration
Section titled “Build with nix-cargo-integration”The development environment and building with Nix are taken care of by nix-cargo-integration (options).
The dependency on Nix is taken care of with the [nix-bindings-rust flake-parts module]!().
Example usage:
{ outputs = inputs@{ self, flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { imports = [ inputs.nix-cargo-integration.flakeModule inputs.nix-bindings-rust.modules.flake.default ];
perSystem = { config, pkgs, ... }: { # optional: nix-bindings-rust.nixPackage = pkgs.nix;
nci.projects."myproject" = { depsDrvConfig = { imports = [ config.nix-bindings-rust.nciBuildConfig ]; }; }; }; };}Hacking
Section titled “Hacking”The following will open a shell with dependencies, and install pre-commit for automatic formatting.
$ nix developVSCode
Section titled “VSCode”rust-analyzer
Section titled “rust-analyzer”If the rust-analyzer extension fails, make sure the devShell was loaded into VSCode via Nix Env Selector or direnv.
[C API] !: https://nix.dev/manual/nix/latest/c-api.html