Warning
Using Determinate Nix Installer as a Rust library is still experimental. This feature is likely to be removed in the future without an advocate. If you're using this, please let us know and we can provide a path to stabilization.
Add the nix-installer library to your dependencies:
cargo add nix-installerIf you're building a CLI, check out the cli feature flag for clap integration.
You'll also need to edit your .cargo/config.toml to use tokio_unstable as we utilize Tokio's process groups, which wrap stable std APIs, but are unstable due to it requiring an MSRV bump:
# .cargo/config.toml
[build]
rustflags=["--cfg", "tokio_unstable"]You'll also need to set the NIX_INSTALLER_TARBALL_PATH environment variable to point to a target-appropriate Nix installation tarball, like nix-2.21.2-aarch64-darwin.tar.xz.
The contents are embedded in the resulting binary instead of downloaded at installation time.
Then it's possible to review the documentation:
cargo doc --open -p nix-installerDocumentation is also available via nix build:
nix build github:DeterminateSystems/nix-installer#nix-installer.doc
firefox result-doc/nix-installer/index.html