diff --git a/hacking/nix/scope/default.nix b/hacking/nix/scope/default.nix index ea187e245..84fc14362 100644 --- a/hacking/nix/scope/default.nix +++ b/hacking/nix/scope/default.nix @@ -83,7 +83,20 @@ superCallPackage ../rust-utils {} self // inherit fenix; - topLevelRustToolchainFile = ../../../rust-toolchain.toml; + topLevelRustToolchainFile = rec { + path = ../../../rust-toolchain.toml; + attrs = builtins.fromTOML (builtins.readFile path); + }; + + assembleRustToolchain = args: + let + toolchain = fenix.toolchainOf args; + profile = topLevelRustToolchainFile.attrs.toolchain.profile or "default"; + explicitComponents = topLevelRustToolchainFile.attrs.toolchain.components; + allComponents = toolchain.manifest.profiles.${profile} ++ explicitComponents; + filteredComponents = lib.filter (component: toolchain ? ${component}) allComponents; + in + toolchain.withComponents filteredComponents; defaultRustEnvironment = let @@ -98,11 +111,11 @@ superCallPackage ../rust-utils {} self // defaultUpstreamRustEnvironment = elaborateRustEnvironment (mkDefaultElaborateRustEnvironmentArgs { rustToolchain = fenix.fromToolchainFile { - file = topLevelRustToolchainFile; + file = topLevelRustToolchainFile.path; sha256 = "sha256-L1F7kAfo8YWrKXHflUaVvCELdvnK2XjcL/lwopFQX2c="; }; } // { - channel = (builtins.fromTOML (builtins.readFile topLevelRustToolchainFile)).toolchain.channel; + channel = topLevelRustToolchainFile.attrs.toolchain.channel; compilerRTSource = mkCompilerRTSource { version = "19.1-2024-07-30"; hash = "sha256-fV51iDAbkRmWJj0twTmQKdZdLueMAKSZR6bBtgVPCbk="; diff --git a/hacking/nix/scope/ferrocene/default.nix b/hacking/nix/scope/ferrocene/default.nix index 13afab137..cdfb435d4 100644 --- a/hacking/nix/scope/ferrocene/default.nix +++ b/hacking/nix/scope/ferrocene/default.nix @@ -12,6 +12,7 @@ , zlib , fenix +, assembleRustToolchain , crateUtils , elaborateRustEnvironment , mkDefaultElaborateRustEnvironmentArgs @@ -169,38 +170,40 @@ let # DO NOT CHECK IN THIS FILE hashesFilePath = ./SHA256SUMS; - # upstreamChannel = "1.79.0"; - upstreamChannel = "beta"; + upstreamChannel = "1.83.0-beta.2"; + upstreamDate = null; - # versionTag = "24.08.0"; - versionTag = "6ce9c7ddc"; - versionName = "pre-rolling-2024-09-11"; + versionTag = builtins.substring 0 9 versionRev; + versionRev = "eecd617bc6f3c693099a1ba900abb93ab9db9196"; + versionName = "nightly-2024-10-30"; repo = fetchFromGitHub { owner = "ferrocene"; repo = "ferrocene"; - rev = "6ce9c7ddc767a9b4cddd4ef8a0d4a317bb63159a"; # branch release/1.82 - hash = "sha256-r1s3ifDA9QF9dCPieChFjJo9cwEY6vi5RMtXWyUiw0g="; + rev = versionRev; + hash = "sha256-HZBJOESd2O0IGX80YmgjLduO1S8CM7VSQxf85FwJw/8="; }; libcManifestDir = "${repo}/ferrocene/library/libc"; - upstreamRustToolchain = fenix.fromToolchainFile { - file = crateUtils.toTOMLFile "rust-toolchain.toml" { - toolchain = { - channel = upstreamChannel; - components = [ "rustc-dev" ]; - }; - }; - sha256 = "sha256-4vvAuAhW4cBwR+g1IrI79X7gKL4VsEYKD05XZL0rLc4="; - }; + upstreamRustToolchain = assembleRustToolchain ({ + channel = upstreamChannel; + sha256 = "sha256-qaGpvEOo1j+3K/YLVFdvVoD6+E3J32U2PmIIb6+FBxw="; + } // lib.optionalAttrs (upstreamDate != null) { + date = upstreamDate; + }); - upstreamRustEnvironment = lib.fix (self: elaborateRustEnvironment (mkDefaultElaborateRustEnvironmentArgs { - rustToolchain = upstreamRustToolchain; + mkRustEnvironment = rustToolchain: lib.fix (self: elaborateRustEnvironment (mkDefaultElaborateRustEnvironmentArgs { + inherit rustToolchain; } // { channel = upstreamChannel; + mkCustomTargetPath = mkMkCustomTargetPathForEnvironment { + rustEnvironment = upstreamRustEnvironment; + }; })); + upstreamRustEnvironment = mkRustEnvironment upstreamRustToolchain; + rustToolchain = mkToolchain { inherit hashesFilePath; arch = hostPlatform.config; @@ -208,14 +211,7 @@ let inherit libcManifestDir; }; - rustEnvironment = lib.fix (self: elaborateRustEnvironment (mkDefaultElaborateRustEnvironmentArgs { - inherit rustToolchain; - } // { - channel = upstreamChannel; - mkCustomTargetPath = mkMkCustomTargetPathForEnvironment { - rustEnvironment = upstreamRustEnvironment; - }; - })); + rustEnvironment = mkRustEnvironment rustToolchain; in { inherit rustEnvironment; diff --git a/hacking/nix/scope/verus/default.nix b/hacking/nix/scope/verus/default.nix index 79bd44f34..5fe844282 100644 --- a/hacking/nix/scope/verus/default.nix +++ b/hacking/nix/scope/verus/default.nix @@ -12,7 +12,7 @@ , crateUtils , vendorLockfile , sources -, fenix +, assembleRustToolchain , elaborateRustEnvironment , mkDefaultElaborateRustEnvironmentArgs , mkMkCustomTargetPathForEnvironment @@ -23,13 +23,8 @@ 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" ]; - } - ]); + rustToolchain = assembleRustToolchain { + channel = "1.76.0"; sha256 = "sha256-e4mlaJehWBymYxJGgnbuCObVlqMlQSilZ8FljG9zPHY="; }; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7a34ba3b9..5069f063a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -7,3 +7,4 @@ [toolchain] channel = "nightly-2024-10-26" components = [ "rust-src", "rustc-dev", "llvm-tools-preview" ] +profile = "default"