Skip to content

Commit

Permalink
Build flake packages with stable Rust (helix-editor#8133)
Browse files Browse the repository at this point in the history
We can continue to use the MSRV for local development and checks while
building release executables with the latest stable Rust, as we do in
CI.
  • Loading branch information
the-mikedavis authored and dgkf committed Jan 30, 2024
1 parent f2a2c2e commit 8389772
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
then ''$RUSTFLAGS -C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment''
else "$RUSTFLAGS";
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
craneLibMSRV = (crane.mkLib pkgs).overrideToolchain rustToolchain;
craneLibStable = (crane.mkLib pkgs).overrideToolchain pkgs.pkgsBuildHost.rust-bin.stable.latest.default;
commonArgs =
{
inherit stdenv;
Expand All @@ -133,13 +134,13 @@
doCheck = false;
meta.mainProgram = "hx";
}
// craneLib.crateNameFromCargoToml {cargoToml = ./helix-term/Cargo.toml;};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
// craneLibMSRV.crateNameFromCargoToml {cargoToml = ./helix-term/Cargo.toml;};
cargoArtifacts = craneLibMSRV.buildDepsOnly commonArgs;
in {
packages = {
helix-unwrapped = craneLib.buildPackage (commonArgs
helix-unwrapped = craneLibStable.buildPackage (commonArgs
// {
inherit cargoArtifacts;
cargoArtifacts = craneLibStable.buildDepsOnly commonArgs;
postInstall = ''
mkdir -p $out/share/applications $out/share/icons/hicolor/scalable/apps $out/share/icons/hicolor/256x256/apps
cp contrib/Helix.desktop $out/share/applications
Expand All @@ -155,20 +156,20 @@
# Build the crate itself
inherit (self.packages.${system}) helix;

clippy = craneLib.cargoClippy (commonArgs
clippy = craneLibMSRV.cargoClippy (commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});

fmt = craneLib.cargoFmt commonArgs;
fmt = craneLibMSRV.cargoFmt commonArgs;

doc = craneLib.cargoDoc (commonArgs
doc = craneLibMSRV.cargoDoc (commonArgs
// {
inherit cargoArtifacts;
});

test = craneLib.cargoTest (commonArgs
test = craneLibMSRV.cargoTest (commonArgs
// {
inherit cargoArtifacts;
});
Expand Down

0 comments on commit 8389772

Please sign in to comment.