Skip to content

Rust

languages.rust.enable

Whether to enable tools for Rust development.

Type: boolean

Default: false

Example: true

languages.rust.channel

The rustup toolchain to install.

Type: one of “nixpkgs”, “stable”, “beta”, “nightly”

Default: "nixpkgs"

languages.rust.components

List of Rustup components to install. Defaults to core components only. Development tools like clippy, rustfmt, and rust-analyzer are controlled by the dev options.

Type: list of string

Default: [ "rustc" "cargo" ]

languages.rust.dev.enable

Enable Rust development tools.

Type: boolean

Default: true

languages.rust.dev.formatter.enable

Enable rustfmt formatter.

Type: boolean

Default: true

languages.rust.dev.formatter.package

The rustfmt package to use.

Type: package

Default: cfg.toolchain.rustfmt or pkgs.rustfmt

languages.rust.dev.linter.enable

Enable clippy linter.

Type: boolean

Default: true

languages.rust.dev.linter.package

The clippy package to use.

Type: package

Default: cfg.toolchain.clippy or pkgs.clippy

languages.rust.dev.lsp.enable

Enable rust-analyzer language server.

Type: boolean

Default: true

languages.rust.dev.lsp.package

The rust-analyzer package to use.

Type: package

Default: cfg.toolchain.rust-analyzer or pkgs.rust-analyzer

languages.rust.mold.enable

Enable mold as the linker.

Enabled by default on x86_64 Linux machines when no cross-compilation targets are specified.

Type: boolean

Default: pkgs.stdenv.isLinux && pkgs.stdenv.isx86_64 && languages.rust.targets == [ ]

languages.rust.rustflags

Extra flags to pass to the Rust compiler.

Type: string

Default: ""

languages.rust.targets

List of extra targets to install. Defaults to only the native target.

Type: list of string

Default: [ ]

languages.rust.toolchain

Rust component packages. May optionally define additional components, for example miri.

Type: attribute set of package

Default: nixpkgs

languages.rust.toolchain.cargo

cargo package

Type: null or package

Default: pkgs.cargo

languages.rust.toolchain.clippy

clippy package

Type: null or package

Default: pkgs.clippy

languages.rust.toolchain.rust-analyzer

rust-analyzer package

Type: null or package

Default: pkgs.rust-analyzer

languages.rust.toolchain.rustc

rustc package

Type: null or package

Default: pkgs.rustc

languages.rust.toolchain.rustfmt

rustfmt package

Type: null or package

Default: pkgs.rustfmt

languages.rust.version

Which version of rust to use, this value could be latest,1.81.0, 2021-01-01. Only works when languages.rust.channel is NOT nixpkgs.

Type: string

Default: "latest"