nixVersions.nix_2_28: unbreak builds on linux

Nix 2.28 seems to have been unbuildable for a long time due to
https://github.com/NixOS/nix/issues/11295.

This particularly surfaces in advanced CI setups where the store
locations are non standard and build user separation disappears as the
build system seems to be hiding bugs using these features.

Reproducing the issue that this commit fixes can be achieved by running:

$ nix-build '<nixpkgs>' -A nixVersions.nix_2_28 --store /tmp/alt --check

This only fixes Linux builds as they are the only "truly" affected by
this.

This commit can be reverted once upstream fixes this issue.

Change-Id: I55d7adee2dee7c735490f33395ba061c27cf4319
Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
Raito Bezarius
2025-12-31 16:54:29 +01:00
committed by Raito Bezarius
parent cbf2ace001
commit 9bb47cfb5e

View File

@@ -174,6 +174,17 @@ stdenv.mkDerivation (finalAttrs: {
postPatch = ''
patchShebangs --build tests
''
# The ability to chmod the root filesystem only exist in filesystem namespacing capable Nix interpreters.
# At the time of writing, only Linux can do it.
+ lib.optionalString stdenv.hostPlatform.isLinux ''
# The build system produces $HOME during the install check phase
# and will fail when ran without build user separation.
# This will surface as a FIFO synchronization deadlock.
# To avoid this, the $HOME directory is barred from being mkdir()
# by the build system here.
# https://github.com/NixOS/nix/issues/11295
chmod 555 /
'';
preConfigure =