1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-31 04:04:45 +00:00

{activation-scripts,activate-system}: check gcroots before linking

When `nix.enable` is off, we don’t necessarily have an active
Nix installation, so there won’t necessarily be an active
`/nix/var/nix/gcroots` directory to link things into. NixOS just skips
this unconditionally when `nix.enable` is off, but that doesn’t
work well with a context in which we usually expect `nix.enable`
to be coupled with an unmanaged system installation of Nix.

(cherry picked from commit 731910af01)
This commit is contained in:
Emily 2025-02-11 19:46:21 +00:00
parent 67d262f923
commit d0f10e610f
2 changed files with 6 additions and 2 deletions
modules
services/activate-system
system

View file

@ -21,7 +21,9 @@
ln -sfn $(cat ${config.system.profile}/systemConfig) /run/current-system
# Prevent the current configuration from being garbage-collected.
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
if [[ -d /nix/var/nix/gcroots ]]; then
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
fi
${config.system.activationScripts.etcChecks.text}
${config.system.activationScripts.etc.text}

View file

@ -109,7 +109,9 @@ in
ln -sfn "$(readlink -f "$systemConfig")" /run/current-system
# Prevent the current configuration from being garbage-collected.
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
if [[ -d /nix/var/nix/gcroots ]]; then
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
fi
exit $_status
'';