nix-cargo-integration
Easily integrate your Rust projects into Nix.
Installation
See the readme.
Options
perSystem.nci.crates.<name>.depsOverrides
perSystem.nci.crates.<name>.export
perSystem.nci.crates.<name>.overrides
perSystem.nci.crates.<name>.profiles
perSystem.nci.crates.<name>.profiles.<name>.features
perSystem.nci.crates.<name>.profiles.<name>.runTests
perSystem.nci.crates.<name>.renameTo
perSystem.nci.crates.<name>.runtimeLibs
perSystem.nci.outputs.<name>.packages
perSystem.nci.outputs.<name>.devShell
perSystem.nci.projects.<name>.depsOverrides
perSystem.nci.projects.<name>.export
perSystem.nci.projects.<name>.overrides
perSystem.nci.projects.<name>.profiles
perSystem.nci.projects.<name>.profiles.<name>.features
perSystem.nci.projects.<name>.profiles.<name>.runTests
perSystem.nci.projects.<name>.relPath
perSystem.nci.projects.<name>.runtimeLibs
perSystem.nci.toolchains.build
perSystem.nci.toolchains.shell
nci.source
The source path that will be used as the ‘flake root’. By default this points to the directory ‘flake.nix’ is in.
Type: path
Default: "self"
Declared by:
nix-cargo-integration/src/interface.nix
perSystem.nci.crates
Crate configurations
Type: lazy attribute set of (submodule)
Default: { }
Example:
{
my-crate = {
export = true;
overrides = {/* stuff */};
};
}
Declared by:
nix-cargo-integration/src/interface.nix
perSystem.nci.crates.<name>.depsOverrides
Overrides to apply to this crate’s dependency derivations (see dream2nix Rust docs for crane) Any overrides here that have the same name as project-wide overrides will take precedence over project-wide ones.
Type: attribute set of (attribute set)
Default: { }
Example:
{
add-env = {TEST_ENV = 1;};
add-inputs.overrideAttrs = old: {
buildInputs = (old.buildInputs or []) ++ [pkgs.hello];
};
}
Declared by:
nix-cargo-integration/src/modules/crate.nix
perSystem.nci.crates.<name>.export
Whether to export this all of this crate’s outputs (if set will override project-wide setting)
Type: null or boolean
Default: null
Example: true
Declared by:
nix-cargo-integration/src/modules/crate.nix
perSystem.nci.crates.<name>.overrides
Overrides to apply to this crate (see dream2nix Rust docs for crane) Any overrides here that have the same name as project-wide overrides will take precedence over project-wide ones.
Type: attribute set of (attribute set)
Default: { }
Example:
{
add-env = {TEST_ENV = 1;};
add-inputs.overrideAttrs = old: {
buildInputs = (old.buildInputs or []) ++ [pkgs.hello];
};
}
Declared by:
nix-cargo-integration/src/modules/crate.nix
perSystem.nci.crates.<name>.profiles
Profiles to generate packages for this crate (if set will override project-wide setting)
Type: null or (attribute set of (submodule))
Default: null
Example:
{
dev = {};
release.runTests = true;
custom-profile.features = ["some" "features"];
}
Declared by:
nix-cargo-integration/src/modules/crate.nix
perSystem.nci.crates.<name>.profiles.<name>.features
Features to enable for this profile. Set to ‘null’ to enable default features only (this is the default). If set to a list of features then ‘–no-default-features’ will be passed to Cargo. If you want to also enable default features you can add ‘default’ feature to the list of features.
Type: null or (list of string)
Default: "[\"default\"]"
Example:
["tracing" "publish"]
Declared by:
nix-cargo-integration/src/modules/profile.nix
perSystem.nci.crates.<name>.profiles.<name>.runTests
Whether to run tests for this profile
Type: boolean
Default: false
Example: true
Declared by:
nix-cargo-integration/src/modules/profile.nix
perSystem.nci.crates.<name>.renameTo
What to rename this crate’s outputs to in
nix flake show
Type: null or string
Default: null
Declared by:
nix-cargo-integration/src/modules/crate.nix
perSystem.nci.crates.<name>.runtimeLibs
Runtime libraries that will be:
patched into the binary at build time,
present in
LD_LIBRARY_PATH
environment variable in development shell.
Note that when it’s patched in at build time, a separate derivation
will be created that “wraps” the original derivation to not cause the
whole crate to recompile when you only change runtimeLibs
.
The original derivation can be accessed via
.passthru.unwrapped
attribute.
Type: list of package
Default: [ ]
Example:
[pkgs.alsa-lib pkgs.libxkbcommon]
Declared by:
nix-cargo-integration/src/modules/crate.nix
perSystem.nci.outputs
Each crate’s (or project’s) outputs
Type: lazy attribute set of (submodule) (read only)
Declared by:
nix-cargo-integration/src/interface.nix
perSystem.nci.outputs.<name>.packages
Packages of this crate mapped to profiles
Type: lazy attribute set of package (read only)
Declared by:
nix-cargo-integration/src/modules/output.nix
perSystem.nci.outputs.<name>.devShell
The development shell for this crate
Type: package (read only)
Declared by:
nix-cargo-integration/src/modules/output.nix
perSystem.nci.projects
Projects (workspaces / crates) to generate outputs for
Type: lazy attribute set of (submodule)
Default: { }
Example:
{
my-crate.relPath = "path/to/crate";
# empty path for projects at flake root
my-workspace.relPath = "";
}
Declared by:
nix-cargo-integration/src/interface.nix
perSystem.nci.projects.<name>.depsOverrides
depsOverrides
option that will affect all packages in
this project. For more information refer to
nci.crates.<name>.depsOverrides
option.
Type: attribute set of (attribute set)
Default: { }
Example:
{
add-env = {TEST_ENV = 1;};
add-inputs.overrideAttrs = old: {
buildInputs = (old.buildInputs or []) ++ [pkgs.hello];
};
}
Declared by:
nix-cargo-integration/src/modules/project.nix
perSystem.nci.projects.<name>.export
export
option that will affect all packages in this
project. For more information refer to
nci.crates.<name>.export
option.
Type: boolean
Default: false
Example: true
Declared by:
nix-cargo-integration/src/modules/project.nix
perSystem.nci.projects.<name>.overrides
overrides
option that will affect all packages in this
project. For more information refer to
nci.crates.<name>.overrides
option.
Type: attribute set of (attribute set)
Default: { }
Example:
{
add-env = {TEST_ENV = 1;};
add-inputs.overrideAttrs = old: {
buildInputs = (old.buildInputs or []) ++ [pkgs.hello];
};
}
Declared by:
nix-cargo-integration/src/modules/project.nix
perSystem.nci.projects.<name>.profiles
profiles
option that will affect all packages in this
project. For more information refer to
nci.crates.<name>.profiles
option.
Type: attribute set of (submodule)
Default:
{
dev = { };
release = {
runTests = true;
};
}
Example:
{
dev = {};
release.runTests = true;
custom-profile.features = ["some" "features"];
}
Declared by:
nix-cargo-integration/src/modules/project.nix
perSystem.nci.projects.<name>.profiles.<name>.features
Features to enable for this profile. Set to ‘null’ to enable default features only (this is the default). If set to a list of features then ‘–no-default-features’ will be passed to Cargo. If you want to also enable default features you can add ‘default’ feature to the list of features.
Type: null or (list of string)
Default: "[\"default\"]"
Example:
["tracing" "publish"]
Declared by:
nix-cargo-integration/src/modules/profile.nix
perSystem.nci.projects.<name>.profiles.<name>.runTests
Whether to run tests for this profile
Type: boolean
Default: false
Example: true
Declared by:
nix-cargo-integration/src/modules/profile.nix
perSystem.nci.projects.<name>.relPath
The path of this project relative to the flake’s root
Type: string
Default: ""
Example: "path/to/project"
Declared by:
nix-cargo-integration/src/modules/project.nix
perSystem.nci.projects.<name>.runtimeLibs
runtimeLibs
option that will affect all packages in this
project. For more information refer to
nci.crates.<name>.runtimeLibs
option.
Type: list of package
Default: [ ]
Example:
[pkgs.alsa-lib pkgs.libxkbcommon]
Declared by:
nix-cargo-integration/src/modules/project.nix
perSystem.nci.toolchains.build
The toolchain that will be used when building derivations
Type: package
Declared by:
nix-cargo-integration/src/interface.nix
perSystem.nci.toolchains.shell
The toolchain that will be used in the development shell
Type: package
Declared by: