Skip to content

The agent that grows with you

fix(nix): the dev shell evaluates and builds on darwin

ethernet0663b92ce9ed
diff --git a/nix/npm-pinned.nix b/nix/npm-pinned.nix
index b2b422c0cdb..bf960f5b7b0 100644
--- a/nix/npm-pinned.nix
+++ b/nix/npm-pinned.nix
@@ -2,11 +2,8 @@
stdenv,
makeWrapper,
fetchurl,
- nodejs_26,
- # The interpreter the wrapper launches. Defaults to nixpkgs, but the dev
- # shell passes the pm-pinned node so `npm` runs on the same node as the
- # rest of that environment.
- nodejs ? nodejs_26,
+ # The node the wrapper launches; lib.nix passes the pm-pinned one.
+ nodejs,
}:
let
# pm/lock.json is the one pin table. Every artifact carries its resolved
diff --git a/nix/pm-packages.nix b/nix/pm-packages.nix
index 93dbaf2f04e..7ba9b577f21 100644
--- a/nix/pm-packages.nix
+++ b/nix/pm-packages.nix
@@ -47,7 +47,9 @@ let
# RPATH. autoPatchelf rewrites that into a literal path and leaves the
# interpreter unable to load its own stdlib, so for it the ELF interpreter
# and RPATH are set explicitly: $ORIGIN stays, and Nix's glibc is appended.
- originRpath = name: name == "python";
+ # Only Linux artifacts are ELF; darwin's Mach-O builds run as shipped.
+ originRpath = name: stdenv.hostPlatform.isLinux && name == "python";
+ patchElf = name: stdenv.hostPlatform.isLinux && name != "python";
derive = name: pin: artifacts:
stdenv.mkDerivation {
@@ -65,7 +67,7 @@ let
sourceRoot = ".";
nativeBuildInputs =
lib.optionals (originRpath name) [ patchelf ]
- ++ lib.optional (!originRpath name) autoPatchelfHook
+ ++ lib.optional (patchElf name) autoPatchelfHook
++ lib.optional (lib.any (a: lib.hasSuffix ".zip" a.url) artifacts) unzip;
# The upstream tarballs are glibc-linked (interpreter
# /lib64/ld-linux-x86-64.so.2, which only exists on a host with nix-ld).
@@ -93,16 +95,16 @@ let
installPhase = ''
mkdir -p $out
cp -r . $out/
+ # Nix's build-environment dump, not artifact content.
+ rm -f $out/env-vars
# Archives wrap their tree in one versioned directory
# (`uv-x86_64-unknown-linux-gnu/`, `node-v26.12.1-linux-x64/`, `package/`).
# pm's store strips it; mirror that so `$out/bin` is the entry point
- # instead of `$out/<archive-name>/bin`. `env-vars` is Nix's own file
- # in $out by the time installPhase runs, so it never counts as content.
+ # instead of `$out/<archive-name>/bin`.
shopt -s dotglob nullglob
wrapped=() stray=()
for entry in "$out"/*; do
- [ "$(basename "$entry")" = env-vars ] && continue
if [ -d "$entry" ]; then wrapped+=("$entry"); else stray+=("$entry"); fi
done
if [ ''${#wrapped[@]} -eq 1 ] && [ ''${#stray[@]} -eq 0 ]; then
diff --git a/nix/sandbox.nix b/nix/sandbox.nix
index c727274214c..b9a36a7c063 100644
--- a/nix/sandbox.nix
+++ b/nix/sandbox.nix
@@ -33,6 +33,7 @@
writeShellApplication,
lib,
+ stdenv,
}:
let
electronRuntime = [
@@ -68,8 +69,10 @@ let
in
writeShellApplication {
name = "sandbox";
- text = ''
+ # darwin's Electron is self-contained, and these libraries are Linux-only.
+ text = lib.optionalString stdenv.isLinux ''
export LD_LIBRARY_PATH=${lib.makeLibraryPath electronRuntime}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
+ '' + ''
exec ${../scripts/dev-sandbox.sh} "$@"
'';
}