From ce7dbe37f8cd8fd90fc8638151d679c9da2f6f57 Mon Sep 17 00:00:00 2001 From: Lucy Menon <168595099+syntactically@users.noreply.github.com> Date: Tue, 2 Sep 2025 16:37:25 +0100 Subject: [PATCH 1/4] [nix] Switch to using postHook instead of shellHook to override PATH This makes it work better with `nix print-dev-env` and friends. Signed-off-by: Simon Davies --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index d700857ac..2c3916a3d 100644 --- a/flake.nix +++ b/flake.nix @@ -140,7 +140,7 @@ RUST_NIGHTLY = "${toolchains.nightly.rust}"; # Set this through shellHook rather than nativeBuildInputs to be # really sure that it overrides the real cargo. - shellHook = '' + postHook = '' export PATH="${fake-rustup}/bin:$PATH" ''; }).overrideAttrs(oA: { From b055b0cb392e52f671fb86af2733a2e54637a515 Mon Sep 17 00:00:00 2001 From: Lucy Menon <168595099+syntactically@users.noreply.github.com> Date: Sun, 5 Oct 2025 15:35:04 +0100 Subject: [PATCH 2/4] [nix] Update Rust versions Signed-off-by: Simon Davies --- flake.nix | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index 2c3916a3d..1171e1192 100644 --- a/flake.nix +++ b/flake.nix @@ -42,27 +42,19 @@ # for rustfmt and old toolchains to verify MSRV toolchains = lib.mapAttrs (_: customisedRustChannelOf) { stable = { - # Stay on 1.87 for development due to the - # quickly-reversed default enablement of - # #[warn(clippy::uninlined_format_args)] - date = "2025-05-15"; + date = "2025-09-18"; channel = "stable"; - sha256 = "sha256-KUm16pHj+cRedf8vxs/Hd2YWxpOrWZ7UOrwhILdSJBU="; + sha256 = "sha256-SJwZ8g0zF2WrKDVmHrVG3pD2RGoQeo24MEXnNx5FyuI="; }; nightly = { date = "2025-07-29"; channel = "nightly"; sha256 = "sha256-6D2b7glWC3jpbIGCq6Ta59lGCKN9sTexhgixH4Y7Nng="; }; - "1.85" = { - date = "2025-02-20"; + "1.88" = { + date = "2025-06-26"; channel = "stable"; - sha256 = "sha256-AJ6LX/Q/Er9kS15bn9iflkUwcgYqRQxiOIL2ToVAXaU="; - }; - "1.86" = { - date = "2025-04-03"; - channel = "stable"; - sha256 = "sha256-X/4ZBHO3iW0fOenQ3foEvscgAPJYl2abspaBThDOukI="; + sha256 = "sha256-Qxt8XAuaUR2OMdKbN4u8dBJOhSHxS+uS06Wl9+flVEk="; }; }; From 805dec8e173146f453a1920d92148bb2ee4e3b0e Mon Sep 17 00:00:00 2001 From: Lucy Menon <168595099+syntactically@users.noreply.github.com> Date: Sun, 5 Oct 2025 15:35:12 +0100 Subject: [PATCH 3/4] [nix] Replace cargoHash with importing the Cargo.lock file Signed-off-by: Simon Davies --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 1171e1192..d3938f239 100644 --- a/flake.nix +++ b/flake.nix @@ -99,7 +99,7 @@ pname = "hyperlight"; version = "0.0.0"; src = lib.cleanSource ./.; - cargoHash = "sha256-hoeJEBdxaoyLlhQQ4X4Wk5X1QVtQ7RRQYaxkiGg8rWA="; + cargoLock.lockFile = ./Cargo.lock; nativeBuildInputs = [ azure-cli From 7a41b91b7e2e615dbea07ad35b1763c1b26d4c27 Mon Sep 17 00:00:00 2001 From: Lucy Menon <168595099+syntactically@users.noreply.github.com> Date: Tue, 7 Oct 2025 00:34:59 +0100 Subject: [PATCH 4/4] [nix] Apply binutils wrapper to Rust's ld.lld In Rust 1.90, rustc defaults to -fuse-ld=lld, which in turn uses a bundled-with-the-compiler ld.lld driver. That driver was not being properly wrapped, leading to generated executables failing to find libraries due to missing DT_RUNPATH entries. This commit modifies the mozilla Rust overlay to wrap the ld.lld driver. Signed-off-by: Simon Davies --- flake.nix | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index d3938f239..92f8442a1 100644 --- a/flake.nix +++ b/flake.nix @@ -15,10 +15,43 @@ rustChannelOf = args: let orig = pkgs.rustChannelOf args; patchRustPkg = pkg: (pkg.overrideAttrs (oA: { - buildCommand = builtins.replaceStrings + buildCommand = (builtins.replaceStrings [ "rustc,rustdoc" ] [ "rustc,rustdoc,clippy-driver,cargo-clippy" ] - oA.buildCommand; + oA.buildCommand) + (let + wrapperPath = pkgs.path + "/pkgs/build-support/bintools-wrapper/ld-wrapper.sh"; + baseOut = pkgs.clangStdenv.cc.bintools.out; + getStdenvAttrs = drv: (drv.overrideAttrs (oA: { + passthru.origAttrs = oA; + })).origAttrs; + baseEnv = (getStdenvAttrs pkgs.clangStdenv.cc.bintools).env; + baseSubstitutedWrapper = pkgs.replaceVars wrapperPath + { + inherit (baseEnv) + shell coreutils_bin suffixSalt mktemp rm; + use_response_file_by_default = "0"; + prog = null; + out = null; + }; + in '' + # work around a bug in the overlay + ${oA.postInstall} + + # copy over helper scripts that the wrapper needs + (cd "${baseOut}"; find . -type f \( -name '*.sh' -or -name '*.bash' \) -print0) | while read -d $'\0' script; do + mkdir -p "$out/$(dirname "$script")" + substitute "${baseOut}/$script" "$out/$script" --replace-quiet "${baseOut}" "$out" + done + + # TODO: Work out how to make this work with cross builds + ldlld="$out/lib/rustlib/${pkgs.clangStdenv.targetPlatform.config}/bin/gcc-ld/ld.lld"; + if [ -e "$ldlld" ]; then + export prog="$(readlink -f "$ldlld")" + rm "$ldlld" + substitute ${baseSubstitutedWrapper} "$ldlld" --subst-var "out" --subst-var "prog" + chmod +x "$ldlld" + fi + ''); })) // { targetPlatforms = [ "x86_64-linux" ]; badTargetPlatforms = [ ]; @@ -116,6 +149,7 @@ jq jaq gdb + zlib ]; buildInputs = [ pango