summary refs log tree commit diff
path: root/nixos/modules/system/activation/activation-script.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-01-20 18:16:30 +0000
committerAlyssa Ross <hi@alyssa.is>2022-01-20 20:24:32 +0000
commitb1724b2f81b0bb43036d05acca344390ffd9092d (patch)
tree613ff14d71d6c4e83afe6a9aa804aafd0bb89025 /nixos/modules/system/activation/activation-script.nix
parent8120952dc6d24eb628f50cf0d6898bd3778f4bff (diff)
downloadnixpkgs-b1724b2f81b0bb43036d05acca344390ffd9092d.tar
nixpkgs-b1724b2f81b0bb43036d05acca344390ffd9092d.tar.gz
nixpkgs-b1724b2f81b0bb43036d05acca344390ffd9092d.tar.bz2
nixpkgs-b1724b2f81b0bb43036d05acca344390ffd9092d.tar.lz
nixpkgs-b1724b2f81b0bb43036d05acca344390ffd9092d.tar.xz
nixpkgs-b1724b2f81b0bb43036d05acca344390ffd9092d.tar.zst
nixpkgs-b1724b2f81b0bb43036d05acca344390ffd9092d.zip
nixos/activation-script: ensure gcroots dir exists
If the Nix daemon has never been enabled (nix.enable has always been
set to false), the gcroots directory won't exist.  If the Nix daemon
is later enabled, the GC roots for booted-system and current-system
will be missing, and they might end up being garbage collected.  Since
it's cheap to add GC roots even if the daemon will never be enabled,
let's just always add them so we're okay in the case where the daemon
is enabled later.
Diffstat (limited to 'nixos/modules/system/activation/activation-script.nix')
-rw-r--r--nixos/modules/system/activation/activation-script.nix1
1 files changed, 1 insertions, 0 deletions
diff --git a/nixos/modules/system/activation/activation-script.nix b/nixos/modules/system/activation/activation-script.nix
index d6f14d01dba..c04d0fc16b2 100644
--- a/nixos/modules/system/activation/activation-script.nix
+++ b/nixos/modules/system/activation/activation-script.nix
@@ -56,6 +56,7 @@ let
       ln -sfn "$(readlink -f "$systemConfig")" /run/current-system
 
       # Prevent the current configuration from being garbage-collected.
+      mkdir -p /nix/var/nix/gcroots
       ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
 
       exit $_status