Skip to content

Commit

Permalink
nix: Refactor ferrocene expression and bump ferrocene
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <nick@nickspinale.com>
  • Loading branch information
nspin committed Oct 30, 2024
1 parent f919218 commit b810c94
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 37 deletions.
19 changes: 16 additions & 3 deletions hacking/nix/scope/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=";
Expand Down
48 changes: 22 additions & 26 deletions hacking/nix/scope/ferrocene/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
, zlib

, fenix
, assembleRustToolchain
, crateUtils
, elaborateRustEnvironment
, mkDefaultElaborateRustEnvironmentArgs
Expand Down Expand Up @@ -169,53 +170,48 @@ 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;
inherit versionTag versionName;
inherit libcManifestDir;
};

rustEnvironment = lib.fix (self: elaborateRustEnvironment (mkDefaultElaborateRustEnvironmentArgs {
inherit rustToolchain;
} // {
channel = upstreamChannel;
mkCustomTargetPath = mkMkCustomTargetPathForEnvironment {
rustEnvironment = upstreamRustEnvironment;
};
}));
rustEnvironment = mkRustEnvironment rustToolchain;

in {
inherit rustEnvironment;
Expand Down
11 changes: 3 additions & 8 deletions hacking/nix/scope/verus/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
, crateUtils
, vendorLockfile
, sources
, fenix
, assembleRustToolchain
, elaborateRustEnvironment
, mkDefaultElaborateRustEnvironmentArgs
, mkMkCustomTargetPathForEnvironment
Expand All @@ -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=";
};

Expand Down
1 change: 1 addition & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
[toolchain]
channel = "nightly-2024-10-26"
components = [ "rust-src", "rustc-dev", "llvm-tools-preview" ]
profile = "default"

0 comments on commit b810c94

Please sign in to comment.