To avoid needing root on a managed macOS computer, I have my Nix store in my home directory. This mostly works pretty well. However, some development shells rely on old packages, and thus use older channels to get them. These older channels sometimes require small tweaks to work with a non-standard home directory.
22.05 doesn’t have enough padding in the Mach-O header for install_name_tool to rewrite the paths to the longer store path. However, this doesn’t actually break bootstrap, so it works fine just to ignore the errors:
--- a/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh
+++ b/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh
@@ -22,13 +22,13 @@
echo "Patching $i"
id=$(otool -D "$i" | tail -n 1)
- install_name_tool -id "$(dirname $i)/$(basename $id)" $i
+ install_name_tool -id "$(dirname $i)/$(basename $id)" $i || true
libs=$(otool -L "$i" | tail -n +2 | grep -v libSystem | cat)
if [ -n "$libs" ]; then
- install_name_tool -add_rpath $out/lib $i
+ install_name_tool -add_rpath $out/lib $i || true
fi
fi
done
In 25.05, the bootstrap clang binary has scrubbed paths referring to the standard store path. Since they don’t point to a real directory anyway, it’s fine to ignore them rather than erroring:
--- a/pkgs/build-support/wrapper-common/utils.bash
+++ b/pkgs/build-support/wrapper-common/utils.bash
@@ -108,6 +108,7 @@
# directory (including the build directory).
test \
"$p" != "/dev/null" -a \
+ "''${p#"/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-"}" = "$p" -a \
"''${p#"''${NIX_STORE}"}" = "$p" -a \
"''${p#"''${NIX_BUILD_TOP}"}" = "$p" -a \
"''${p#/tmp}" = "$p" -a \
Would it be possible to add small fixes like this to out-of-support channels? It could be conditional on builtins.storeDir being non-standard, so instantiating with a standard store path evaluates exactly the same as before, keeping all of the existing cached binaries valid. If so, what would the process be? (Can I submit a PR directly on the release branch for cases like this?)
This would be very helpful when sharing shell.nix files with other developers, since they could just pin the last branch commit and work everywhere, rather than me having to point them to a patched version of the old release branch manually.