Fenix
Rust toolchains and rust-analyzer nightly for Nix [maintainers=@figsoda, @winterqt, @eureka-cpu]
Install / Use
/learn @nix-community/FenixREADME
fenix
Fenix provides the minimal, default, and complete profile of rust toolchains, latest profile of nightly toolchains, nightly version of rust analyzer and its vscode extension.
It aims to be a replacement for rustup and the rust overlay provided by nixpkgs-mozilla.
Binary cache is available for x86_64-darwin, aarch64-darwin and x86_64-linux on cachix
cachix use nix-community
Note: The nixpkgs from your system will be used when fenix is being used as an overlay, which may not be cached if you are using a stable/older version of nixpkgs. To fix this, use the packages directly or use the following workaround (see #79)
{
nixpkgs.overlays = [
(_: super: let pkgs = fenix.inputs.nixpkgs.legacyPackages.${super.system}; in fenix.overlays.default pkgs pkgs)
];
}
Usage
<details> <summary>As a flake (recommended)</summary>{
inputs = {
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "nixpkgs/nixos-unstable";
};
outputs = { self, fenix, nixpkgs }: {
packages.x86_64-linux.default = fenix.packages.x86_64-linux.minimal.toolchain;
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ pkgs, ... }: {
nixpkgs.overlays = [ fenix.overlays.default ];
environment.systemPackages = [
(pkgs.fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
pkgs.rust-analyzer-nightly
];
})
];
};
};
}
</details>
<details>
<summary>As a set of packages</summary>
let
fenix = import (fetchTarball "https://github.com/nix-community/fenix/archive/main.tar.gz") { };
in
fenix.minimal.toolchain
</details>
<details>
<summary>As an overlay</summary>
# configuration.nix
{ pkgs, ... }: {
nixpkgs.overlays = [
(import "${fetchTarball "https://github.com/nix-community/fenix/archive/main.tar.gz"}/overlay.nix")
];
environment.systemPackages = with pkgs; [
(fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
rust-analyzer-nightly
];
}
</details>
Following is a list of outputs, examples are prefixed with:
with fenix.packages.<system>;(flakes), orwith import (fetchTarball "https://github.com/nix-community/fenix/archive/main.tar.gz") { };
<a name="toolchain"></a>
Some outputs are toolchains, a rust toolchain in fenix is structured like this:
{
# components
cargo = <derivation>;
rustc = <derivation>; # rustc with rust-std
rustc-unwrapped = <derivation>; # rustc without rust-std, same as rustc.unwrapped
rustfmt = <derivation>; # alias to rustfmt-preview
rust-src = <derivation>; # RUST_SRC_PATH = "${fenix.complete.rust-src}/lib/rustlib/src/rust/library"
# ...
# derivation with all the components
toolchain = <derivation>;
# not available in nightly toolchains
# derivation with all the components from a profile
minimalToolchain = <derivation>;
defaultToolchain = <derivation>;
completeToolchain = <derivation>;
# withComponents : [string] -> derivation
# creates a derivation with the given list of components from the toolchain
withComponents = <function>;
}
<details>
<summary><code>combine : [derivation] -> derivation</code></summary>
Combines a list of components into a derivation. If the components are from the same toolchain, use withComponents instead.
combine [
minimal.rustc
minimal.cargo
targets.wasm32-unknown-unknown.latest.rust-std
]
</details>
<details>
<summary><code>fromManifest : attrs -> <a href="#toolchain">toolchain</a></code></summary>
Creates a toolchain from a rustup manifest
fromManifest (lib.importTOML ./channel-rust-nightly.toml)
</details>
<details>
<summary><code>fromManifestFile : path -> <a href="#toolchain">toolchain</a></code></summary>
Creates a toolchain from a rustup manifest file
fromManifestFile ./channel-rust-nightly.toml
</details>
<details>
<summary><code>toolchainOf : attrs -> <a href="#toolchain">toolchain</a></code></summary>
Creates toolchain from given arguments:
argument | default | description
-|-|-
root | "https://static.rust-lang.org/dist" | root url from downloading manifest, usually left as default
channel | "nightly" | rust channel, one of "stable", "beta", "nightly", and version number
date | null | date of the toolchain, latest if unset
sha256 | null | sha256 of the manifest, required in pure evaluation mode, set to lib.fakeSha256 to get the actual sha256 from the error message
toolchainOf {
channel = "beta";
date = "2021-08-29";
sha256 = "0dkmjil9avba6l0l9apmgwa8d0h4f8jzgxkq3gvn8d2xc68ks5a5";
}
toolchainOf {
channel = "1.90.0";
sha256 = "sha256-SJwZ8g0zF2WrKDVmHrVG3pD2RGoQeo24MEXnNx5FyuI=";
}
</details>
<details>
<summary><code>fromToolchainFile : attrs -> derivation</code></summary>
Creates a derivation from a rust toolchain file, accepts the following arguments:
argument | description
-|-
file | path to the rust toolchain file, usually either ./rust-toolchain or ./rust-toolchain.toml, conflicts with dir
dir | path to the directory that has rust-toolchain or rust-toolchain.toml, conflicts with file
sha256 | sha256 of the manifest, required in pure evaluation mode, set to lib.fakeSha256 to get the actual sha256 from the error message
fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = lib.fakeSha256;
}
fromToolchainFile { dir = ./.; }
</details>
<details>
<summary><code>fromToolchainName : attrs -> <a href="#toolchain">toolchain</a></code></summary>
Creates a toolchain from a toolchain name, accepts the following arguments:
argument | description
-|-
name | rust channel, version number, one of "stable", "beta", "nightly", and date.
sha256 | sha256 of the manifest, required in pure evaluation mode, set to lib.fakeSha256 to get the actual sha256 from the error message
fromToolchainName { name = "1.90.0"; sha256 = "sha256-SJwZ8g0zF2WrKDVmHrVG3pD2RGoQeo24MEXnNx5FyuI="; }
fromToolchainName { name = "nightly-2023-08-07"; sha256 = "Ho2/rJSi6KiHbxgDpdvYE0dwrEUD3psnyYyLmFNYKII="; }
fromToolchainName { name = (lib.importTOML ./rust-toolchain.toml).toolchain.channel; }
</details>
<details>
<summary><code>stable : <a href="#toolchain">toolchain</a></code></summary>
The stable toolchain
</details> <details> <summary><code>beta : <a href="#toolchain">toolchain</a></code></summary>The beta toolchain
</details> <details> <summary><code>minimal : <a href="#toolchain">toolchain</a></code></summary>The minimal profile of the nightly toolchain
</details> <details> <summary><code>default : <a href="#toolchain">toolchain</a></code></summary>The default profile of the nightly toolchain, sometimes lags behind the minimal profile
The complete profile of the nightly toolchain, usually lags behind the minimal and default profile
A custom toolchain that contains all the components from the complete profile but not from necessarily the same date.
Unlike the complete profile, you get the latest version of the components, but risks a larger chance of incompatibility.
Toolchains for supported targets, everything mentioned above except for combine is supported
targets.wasm32-unknown-unknown.latest.rust-std
</details>
<details>
<summary><code>rust-analyzer : derivation</code></summary>
Nightly version of rust-analyzer, also available with overlay as rust-analyzer-nightly
# configuration.nix with overlay
{ pkgs, ... }: {
environment.systemPackages = with pkgs; [ rust-analyzer-nightly ];
}
</details>
<details>
<summary><code>rust-analyzer-vscode-extension : derivation</code></summary>
Nightly version of vscode-extensions.rust-lang.rust-analyzer, also available with overlay as vscode-extensions.rust-lang.rust-analyzer-nightly
# with overlay
with pkgs; vscode-with-extensions.override {
vscodeExtensions = [
vscode-extensions.rust-lang.rust-analyzer-nightly
];
}
</details>
Monthly branch
Fenix has a monthly branch that is updated on the 1st of every month, for cases where you want to use rust nightly but don't need it to be updated very often.
{
inputs = {
fenix.url = "github:ni
Related Skills
himalaya
335.2kCLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
node-connect
335.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
coding-agent
335.2kDelegate coding tasks to Codex, Claude Code, or Pi agents via background process
