nix-cargo-integration
Easily integrate your Rust projects into Nix.
Installation
See the readme.
Options
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:
perSystem.devshells
Configure devshells with flake-parts.
Not to be confused with devShells
, with a capital S. Yes, this
is unfortunate.
Each devshell will also configure an equivalent devShells
.
Used to define devshells. not to be confused with devShells
Type: lazy attribute set of (submodule)
Default:
{ }
Declared by:
perSystem.nci.crates
Crate configurations
Type: lazy attribute set of (submodule)
Default:
{ }
Example:
{
my-crate = {
export = true;
};
}
Declared by:
perSystem.nci.crates.<name>.checkProfile
Profile to use for the tests only package
Type: null or string
Default:
null
Example:
"custom-profile"
Declared by:
perSystem.nci.crates.<name>.clippyProfile
Profile to use for clippy only package Note that you will need to add ‘clippy’ as a component to the rust toolchain you are using yourself
Type: null or boolean
Default:
null
Example:
"custom-profile"
Declared by:
perSystem.nci.crates.<name>.depsDrvConfig
Change dependencies derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
perSystem.nci.crates.<name>.drvConfig
Change main derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
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:
perSystem.nci.crates.<name>.numtideDevshell
If set, the given numtide devshell devshells.<name>
will be populated with
the required packages and environment variables to build this crate.
Type: null or string
Default:
null
Declared by:
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:
perSystem.nci.crates.<name>.profiles.<name>.depsDrvConfig
Change dependencies derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
perSystem.nci.crates.<name>.profiles.<name>.drvConfig
Change main derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
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:
perSystem.nci.crates.<name>.profiles.<name>.runTests
Whether to run tests for this profile
Type: boolean
Default:
false
Example:
true
Declared by:
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:
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:
perSystem.nci.crates.<name>.targets
Targets to generate packages for this crate (if set will override project-wide setting)
Type: null or (attribute set of (submodule))
Default:
null
Example:
{
wasm32-unknown-unknown.profiles = ["release"];
x86_64-unknown-linux-gnu.default = true;
}
Declared by:
perSystem.nci.crates.<name>.targets.<name>.default
Whether or not this target is the default target
Type: boolean
Default:
false
Example:
true
Declared by:
perSystem.nci.crates.<name>.targets.<name>.depsDrvConfig
Change dependencies derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
perSystem.nci.crates.<name>.targets.<name>.drvConfig
Change main derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
perSystem.nci.crates.<name>.targets.<name>.profiles
The profiles to generate packages for this target.
Type: null or (list of string)
Default:
"all profiles"
Example:
["dev" "release" "custom-profile"]
Declared by:
perSystem.nci.lib.buildCrate
A function to build a crate from a provided source (and crate name if workspace) automagically
Type: function that evaluates to a(n) package (read only)
Declared by:
perSystem.nci.outputs
Each crate’s (or project’s) outputs
Type: lazy attribute set of (submodule) (read only)
Declared by:
perSystem.nci.outputs.<name>.packages
Packages of this crate mapped to profiles
Type: lazy attribute set of package (read only)
Declared by:
perSystem.nci.outputs.<name>.allTargets
All packages for all targets
Type: lazy attribute set of (submodule) (read only)
Declared by:
perSystem.nci.outputs.<name>.allTargets.<name>.packages
Packages of this crate mapped to profiles
Type: lazy attribute set of package (read only)
Declared by:
perSystem.nci.outputs.<name>.check
Tests only package for this crate
Type: package (read only)
Declared by:
perSystem.nci.outputs.<name>.clippy
Clippy only package for this crate
Type: package (read only)
Declared by:
perSystem.nci.outputs.<name>.devShell
The development shell for this crate
Type: package (read only)
Declared by:
perSystem.nci.projects
Projects (workspaces / crates) to generate outputs for
Type: lazy attribute set of (submodule)
Default:
{ }
Example:
{
# define the absolute path to the project
my-project.path = ./.;
}
Declared by:
perSystem.nci.projects.<name>.checkProfile
checkProfile
option that will affect all packages in this project.
For more information refer to nci.crates.<name>.checkProfile
option.
Type: string
Default:
"release"
Example:
"custom-profile"
Declared by:
perSystem.nci.projects.<name>.clippyProfile
clippyProfile
option that will affect all packages in this project.
For more information refer to nci.crates.<name>.clippyProfile
option.
Type: string
Default:
"dev"
Example:
"custom-profile"
Declared by:
perSystem.nci.projects.<name>.depsDrvConfig
Change dependencies derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
perSystem.nci.projects.<name>.drvConfig
Change main derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
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:
true
Example:
false
Declared by:
perSystem.nci.projects.<name>.numtideDevshell
If set, the given numtide devshell devshells.<name>
will be populated with
the required packages and environment variables to build this crate.
Type: null or string
Default:
null
Declared by:
perSystem.nci.projects.<name>.path
The absolute path of this project
Type: path
Example:
"./path/to/project"
Declared by:
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:
perSystem.nci.projects.<name>.profiles.<name>.depsDrvConfig
Change dependencies derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
perSystem.nci.projects.<name>.profiles.<name>.drvConfig
Change main derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
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:
perSystem.nci.projects.<name>.profiles.<name>.runTests
Whether to run tests for this profile
Type: boolean
Default:
false
Example:
true
Declared by:
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:
perSystem.nci.projects.<name>.targets
targets
option that will affect all packages in this project.
For more information refer to nci.crates.<name>.targets
option.
Type: attribute set of (submodule)
Default:
''
{
<host platform>.default = true;
}
''
Example:
{
wasm32-unknown-unknown.profiles = ["release"];
x86_64-unknown-linux-gnu.default = true;
}
Declared by:
perSystem.nci.projects.<name>.targets.<name>.default
Whether or not this target is the default target
Type: boolean
Default:
false
Example:
true
Declared by:
perSystem.nci.projects.<name>.targets.<name>.depsDrvConfig
Change dependencies derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
perSystem.nci.projects.<name>.targets.<name>.drvConfig
Change main derivation configuration
mkDerivation
options must be defined under the mkDerivation
attribute.
Environment variables and non-mkDerivation options must be defined under the env
attribute.
This is passed to dream2nix
as is, so you could also define any other dream2nix module options here (eg. rust-crane
).
Type: attribute set
Default:
{ }
Example:
{
mkDerivation = {
# inputs and most other stuff will automatically merge
buildInputs = [pkgs.hello];
};
# define env variables and options not defined in standard mkDerivation interface like this
env = {
CARGO_TERM_VERBOSE = "true";
someOtherEnvVar = 1;
};
}
Declared by:
perSystem.nci.projects.<name>.targets.<name>.profiles
The profiles to generate packages for this target.
Type: null or (list of string)
Default:
"all profiles"
Example:
["dev" "release" "custom-profile"]
Declared by:
perSystem.nci.toolchainConfig
The toolchain configuration that will be used
Type: null or path or (attribute set)
Default:
null
Example:
./rust-subproject/rust-toolchain.toml
Declared by:
perSystem.nci.toolchains.mkBuild
The function to (given a nixpkgs instance) generate a toolchain that will be used when building derivations
Type: function that evaluates to a(n) package
Declared by:
perSystem.nci.toolchains.mkShell
The function to (given a nixpkgs instance) generate a toolchain that will be used in the development shell
Type: function that evaluates to a(n) package
Declared by: