From e4c22456ef54a2eab5b410ed0fa836dcb33dbfe1 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Mon, 22 May 2023 16:00:34 -0600 Subject: [PATCH] Configure nightly toolchain in crane.nix Get rid of this non-intuitive dependency of cranePkgs.cargoTargets. --- crane.nix | 10 ++++++++-- flake.nix | 10 ++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crane.nix b/crane.nix index 0b6079a..7dd9b0f 100644 --- a/crane.nix +++ b/crane.nix @@ -2,8 +2,8 @@ , pkgs , lib , crane -, rustNightly , rust +, rust-bin , nix-gitignore , supportedSystems }: @@ -11,6 +11,12 @@ let inherit (stdenv.hostPlatform) system; + nightlyVersion = "2023-05-01"; + rustNightly = pkgs.rust-bin.nightly.${nightlyVersion}.default.override { + extensions = [ "rust-src" "rust-analyzer-preview" ]; + targets = cargoTargets; + }; + # For easy cross-compilation in devShells # We are just composing the pkgsCross.*.stdenv.cc together crossPlatforms = let @@ -91,7 +97,7 @@ let }); in crate; in { - inherit crossPlatforms cargoTargets cargoCrossEnvs; + inherit crossPlatforms cargoTargets cargoCrossEnvs rustNightly; nix-actions-cache = buildFor system; } diff --git a/flake.nix b/flake.nix index 1f8a752..acd68ed 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,6 @@ outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }: let supportedSystems = flake-utils.lib.defaultSystems; - nightlyVersion = "2023-05-01"; in flake-utils.lib.eachSystem supportedSystems (system: let pkgs = import nixpkgs { inherit system; @@ -37,13 +36,8 @@ inherit (pkgs) lib; - rustNightly = pkgs.rust-bin.nightly.${nightlyVersion}.default.override { - extensions = [ "rust-src" "rust-analyzer-preview" ]; - targets = cranePkgs.cargoTargets; - }; - cranePkgs = pkgs.callPackage ./crane.nix { - inherit crane supportedSystems rustNightly; + inherit crane supportedSystems; }; in { packages = rec { @@ -55,7 +49,7 @@ inputsFrom = [ cranePkgs.nix-actions-cache ]; packages = with pkgs; [ bashInteractive - rustNightly + cranePkgs.rustNightly cargo-bloat cargo-edit