summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorJanne Heß <janne@hess.ooo>2021-09-12 11:34:13 +0200
committerJanne Heß <janne@hess.ooo>2021-09-12 11:34:13 +0200
commit4db13430fbbe09e51fd281b39c3c2c2d0370ad6f (patch)
tree7797471d439bc6a3f10d1e47f79ae149ceb4cdfb /nixos/modules
parent79f637da440bf715c1d34d772ec5aa11415682c8 (diff)
downloadnixpkgs-4db13430fbbe09e51fd281b39c3c2c2d0370ad6f.tar
nixpkgs-4db13430fbbe09e51fd281b39c3c2c2d0370ad6f.tar.gz
nixpkgs-4db13430fbbe09e51fd281b39c3c2c2d0370ad6f.tar.bz2
nixpkgs-4db13430fbbe09e51fd281b39c3c2c2d0370ad6f.tar.lz
nixpkgs-4db13430fbbe09e51fd281b39c3c2c2d0370ad6f.tar.xz
nixpkgs-4db13430fbbe09e51fd281b39c3c2c2d0370ad6f.tar.zst
nixpkgs-4db13430fbbe09e51fd281b39c3c2c2d0370ad6f.zip
nixos/activation-script: Fix dependencies for dry activation
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/system/activation/activation-script.nix13
1 files changed, 11 insertions, 2 deletions
diff --git a/nixos/modules/system/activation/activation-script.nix b/nixos/modules/system/activation/activation-script.nix
index 548b4de852b..9692e409a98 100644
--- a/nixos/modules/system/activation/activation-script.nix
+++ b/nixos/modules/system/activation/activation-script.nix
@@ -18,8 +18,17 @@ let
   });
 
   systemActivationScript = set: onlyDry: let
-    set' = filterAttrs (_: v: onlyDry -> v.supportsDryActivation) (mapAttrs (_: v: if isString v then (noDepEntry v) // { supportsDryActivation = false; } else v) set);
+    set' = mapAttrs (_: v: if isString v then (noDepEntry v) // { supportsDryActivation = false; } else v) set;
     withHeadlines = addAttributeName set';
+    # When building a dry activation script, this replaces all activation scripts
+    # that do not support dry mode with a comment that does nothing. Filtering these
+    # activation scripts out so they don't get generated into the dry activation script
+    # does not work because when an activation script that supports dry mode depends on
+    # an activation script that does not, the dependency cannot be resolved and the eval
+    # fails.
+    withDrySnippets = mapAttrs (a: v: if onlyDry && !v.supportsDryActivation then v // {
+      text = "#### Activation script snippet ${a} does not support dry activation.";
+    } else v) withHeadlines;
   in
     ''
       #!${pkgs.runtimeShell}
@@ -37,7 +46,7 @@ let
       # Ensure a consistent umask.
       umask 0022
 
-      ${textClosureMap id (withHeadlines) (attrNames withHeadlines)}
+      ${textClosureMap id (withDrySnippets) (attrNames withDrySnippets)}
 
     '' + optionalString (!onlyDry) ''
       # Make this configuration the current configuration.