Use fenix toolchain in nix shell (#18227)
In #17974 we explicitly depend on rustc/cargo for the nix devShell, however the fenix overlay that contains the latest stable versions was not being applied to that shell. This led to the shell inheriting whatever rustc/cargo was on nixos-unstable from nixpkgs, which sometimes lags behind. This change fixes that, and also restructures the flake to ensure that all outputs rely on the overlaid `pkgs`. Release Notes: - N/A
This commit is contained in:
parent
d784e72027
commit
2ff8dde925
3 changed files with 41 additions and 38 deletions
58
flake.nix
58
flake.nix
|
@ -17,27 +17,34 @@
|
|||
fenix,
|
||||
...
|
||||
}: let
|
||||
forAllSystems = function:
|
||||
nixpkgs.lib.genAttrs [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
] (system:
|
||||
function (import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [fenix.overlays.default];
|
||||
}));
|
||||
systems = ["x86_64-linux" "aarch64-linux"];
|
||||
|
||||
overlays = {
|
||||
fenix = fenix.overlays.default;
|
||||
rust-toolchain = final: prev: {
|
||||
rustToolchain = final.fenix.stable.toolchain;
|
||||
};
|
||||
zed-editor = final: prev: {
|
||||
zed-editor = final.callPackage ./nix/build.nix {
|
||||
craneLib = (crane.mkLib final).overrideToolchain final.rustToolchain;
|
||||
rustPlatform = final.makeRustPlatform {
|
||||
inherit (final.rustToolchain) cargo rustc;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
mkPkgs = system:
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
overlays = builtins.attrValues overlays;
|
||||
};
|
||||
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f (mkPkgs system));
|
||||
in {
|
||||
packages = forAllSystems (pkgs: let
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.fenix.stable.toolchain);
|
||||
rustPlatform = pkgs.makeRustPlatform {
|
||||
inherit (pkgs.fenix.stable.toolchain) cargo rustc;
|
||||
};
|
||||
nightlyBuild = pkgs.callPackage ./nix/build.nix {
|
||||
inherit craneLib rustPlatform;
|
||||
};
|
||||
in {
|
||||
zed-editor = nightlyBuild;
|
||||
default = nightlyBuild;
|
||||
packages = forAllSystems (pkgs: {
|
||||
zed-editor = pkgs.zed-editor;
|
||||
default = pkgs.zed-editor;
|
||||
});
|
||||
|
||||
devShells = forAllSystems (pkgs: {
|
||||
|
@ -46,13 +53,10 @@
|
|||
|
||||
formatter = forAllSystems (pkgs: pkgs.alejandra);
|
||||
|
||||
overlays.default = final: prev: {
|
||||
zed-editor = final.callPackage ./nix/build.nix {
|
||||
craneLib = (crane.mkLib final).overrideToolchain (p: p.fenix.stable.toolchain);
|
||||
rustPlatform = final.makeRustPlatform {
|
||||
inherit (final.fenix.stable.toolchain) cargo rustc;
|
||||
};
|
||||
overlays =
|
||||
overlays
|
||||
// {
|
||||
default = nixpkgs.lib.composeManyExtensions (builtins.attrValues overlays);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue