From b1724b2f81b0bb43036d05acca344390ffd9092d Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 20 Jan 2022 18:16:30 +0000 Subject: [PATCH] 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. --- nixos/modules/system/activation/activation-script.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/system/activation/activation-script.nix b/nixos/modules/system/activation/activation-script.nix index d6f14d01dbaa..c04d0fc16b24 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