nix-cargo-integration

Easily integrate your Rust projects into Nix.

Installation

See the readme.

Options

nci.source

perSystem.nci.crates

perSystem.nci.crates.<name>.depsDrvConfig

perSystem.nci.crates.<name>.drvConfig

perSystem.nci.crates.<name>.export

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

perSystem.nci.outputs.<name>.packages

perSystem.nci.outputs.<name>.devShell

perSystem.nci.projects

perSystem.nci.projects.<name>.depsDrvConfig

perSystem.nci.projects.<name>.drvConfig

perSystem.nci.projects.<name>.export

perSystem.nci.projects.<name>.path

perSystem.nci.projects.<name>.profiles

perSystem.nci.projects.<name>.profiles.<name>.features

perSystem.nci.projects.<name>.profiles.<name>.runTests

perSystem.nci.projects.<name>.runtimeLibs

perSystem.nci.toolchainConfig

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;
  };
}

Declared by:

nix-cargo-integration/src/interface.nix

perSystem.nci.crates.<name>.depsDrvConfig

Change dependencies derivation configuration Environment variables must be defined under an attrset called env.

Type: attribute set

Default: { }

Example:

{
  # 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:

nix-cargo-integration/src/modules/crate.nix

perSystem.nci.crates.<name>.drvConfig

Change main derivation configuration Environment variables must be defined under an attrset called env.

Type: attribute set

Default: { }

Example:

{
  # 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:

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>.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:

{
  # define the absolute path to the project
  my-project.path = ./.;
}

Declared by:

nix-cargo-integration/src/interface.nix

perSystem.nci.projects.<name>.depsDrvConfig

Change dependencies derivation configuration Environment variables must be defined under an attrset called env.

Type: attribute set

Default: { }

Declared by:

nix-cargo-integration/src/modules/project.nix

perSystem.nci.projects.<name>.drvConfig

Change main derivation configuration Environment variables must be defined under an attrset called env.

Type: attribute set

Default: { }

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: true

Example: false

Declared by:

nix-cargo-integration/src/modules/project.nix

perSystem.nci.projects.<name>.path

The absolute path of this project

Type: path

Example: "./path/to/project"

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>.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.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:

nix-cargo-integration/src/interface.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:

nix-cargo-integration/src/interface.nix