diff --git a/hacking/nix/scope/default.nix b/hacking/nix/scope/default.nix index 300d6f6c8..7ffa10063 100644 --- a/hacking/nix/scope/default.nix +++ b/hacking/nix/scope/default.nix @@ -98,6 +98,14 @@ superCallPackage ../rust-utils {} self // in toolchain.withComponents filteredComponents; + parseStructuredChannel = unstructuredChannel: + let + parts = builtins.match ''(nightly)-(.*)'' unstructuredChannel; + in + if parts == null + then { channel = unstructuredChannel; date = null; } + else { channel = lib.elemAt parts 0; date = lib.elemAt parts 1; }; + defaultRustEnvironment = let inherit (scopeConfig.rustEnvironmentSelector) tracks upstream; diff --git a/hacking/nix/scope/kani/default.nix b/hacking/nix/scope/kani/default.nix index a3c3dfed9..eb78c57c3 100644 --- a/hacking/nix/scope/kani/default.nix +++ b/hacking/nix/scope/kani/default.nix @@ -16,7 +16,8 @@ , crateUtils , vendorLockfile , sources -, fenix +, assembleRustToolchain +, parseStructuredChannel , elaborateRustEnvironment , mkDefaultElaborateRustEnvironmentArgs , mkMkCustomTargetPathForEnvironment @@ -27,20 +28,16 @@ let rustToolchainAttrs = builtins.fromTOML (builtins.readFile (src + "/rust-toolchain.toml")); - rustToolchain = fenix.fromToolchainFile { - file = crateUtils.toTOMLFile "rust-toolchain.toml" (crateUtils.clobber [ - rustToolchainAttrs - { - toolchain.components = rustToolchainAttrs.toolchain.components ++ [ "rust-src" ]; - } - ]); + inherit (rustToolchainAttrs.toolchain) channel; + + rustToolchain = assembleRustToolchain (parseStructuredChannel channel // { sha256 = "sha256-opDDHyN+Xa9kcjdHwGl3IpBsUw7ikGU+Ng00JeCdkMA="; - }; + }); rustEnvironment = lib.fix (self: elaborateRustEnvironment (mkDefaultElaborateRustEnvironmentArgs { inherit rustToolchain; } // { - inherit (rustToolchainAttrs.toolchain) channel; + inherit channel; mkCustomTargetPath = mkMkCustomTargetPathForEnvironment { rustEnvironment = self; }; diff --git a/hacking/nix/scope/verus/default.nix b/hacking/nix/scope/verus/default.nix index 5fe844282..b1da14fc4 100644 --- a/hacking/nix/scope/verus/default.nix +++ b/hacking/nix/scope/verus/default.nix @@ -23,15 +23,17 @@ let rustToolchainAttrs = builtins.fromTOML (builtins.readFile (src + "/rust-toolchain.toml")); + inherit (rustToolchainAttrs.toolchain) channel; + rustToolchain = assembleRustToolchain { - channel = "1.76.0"; + inherit channel; sha256 = "sha256-e4mlaJehWBymYxJGgnbuCObVlqMlQSilZ8FljG9zPHY="; }; rustEnvironment = lib.fix (self: elaborateRustEnvironment (mkDefaultElaborateRustEnvironmentArgs { inherit rustToolchain; } // { - inherit (rustToolchainAttrs.toolchain) channel; + inherit channel; backwardsCompatibilityHacks = { outDirInsteadOfArtifactDir = true; noLibraryWorkspace = true;