nixos/activation: avoid generating empty activation scripts

This commit is contained in:
r-vdp
2025-11-24 12:33:48 -03:00
parent 1aa98efa4d
commit e16bd36ed6
2 changed files with 9 additions and 7 deletions

View File

@@ -43,7 +43,7 @@
let
inherit (lib)
concatStringsSep
concatMapStringsSep
head
isAttrs
listToAttrs
@@ -166,7 +166,7 @@ rec {
textClosureMap =
f: predefined: names:
concatStringsSep "\n" (map f (textClosureList predefined names));
concatMapStringsSep "\n" f (textClosureList predefined names);
noDepEntry = text: {
inherit text;

View File

@@ -13,17 +13,16 @@ let
addAttributeName = mapAttrs (
a: v:
v
// {
// (lib.optionalAttrs (v.text != "") {
text = ''
#### Activation script snippet ${a}:
_localstatus=0
${v.text}
if (( _localstatus > 0 )); then
printf "Activation script snippet '%s' failed (%s)\n" "${a}" "$_localstatus"
fi
'';
}
})
);
systemActivationScript =
@@ -68,8 +67,11 @@ let
# Ensure a consistent umask.
umask 0022
${textClosureMap id withDrySnippets (attrNames withDrySnippets)}
${lib.concatStringsSep "\n" (
lib.filter (v: v != "") (
textClosureList withDrySnippets (attrNames (lib.filterAttrs (_: v: v.text != "") withDrySnippets))
)
)}
''
+ optionalString (!onlyDry) ''
# Make this configuration the current configuration.