Skip to content

Commit

Permalink
refactor(nix): decouple rust extensions; add toolchains
Browse files Browse the repository at this point in the history
  • Loading branch information
eljamm committed Feb 15, 2025
1 parent 014a7bf commit ae087c7
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions nix/modules/rust.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
{ inputs, ... }:
{
perSystem =
{ system, pkgs, ... }:
{
system,
pkgs,
self',
...
}:
{
# Add rust-overlay to `pkgs`
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ inputs.rust-overlay.overlays.default ];
};

legacyPackages.rust = rec {
extensions = [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
"rust-analyzer"
];

toolchains.stable = pkgs.rust-bin.stable.latest.minimal.override { inherit extensions; };
toolchains.nightly = pkgs.rust-bin.selectLatestNightlyWith (
toolchain: toolchain.minimal.override { inherit extensions; }
);
};

devShells.rust = pkgs.mkShell {
packages = [
(pkgs.rust-bin.selectLatestNightlyWith (
toolchain:
toolchain.minimal.override {
extensions = [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
"rust-analyzer"
];
}
))
self'.legacyPackages.rust.toolchains.nightly
];
};
};
Expand Down

0 comments on commit ae087c7

Please sign in to comment.