Skip to content

Commit 04da25c

Browse files
committed
nixos/activation: no output for empty snippets
There are several empty snippets in a standard configuration. They are present only for backward compatibility with other snippets which may have declared dependencies on them. This patch eliminates the per-snippet boilerplate for empty snippets. If, someday, we get to the point where there are no non-empty activation snippets, then this will lead to an empty string where the snippets used to be. Note that I didn't want newlines inserted where empty scripts used to be either, so rather than using textClosureMap with its built-in "\n" separators, I switched to using the underlying textClosureList, and adding an extra newline only for non-empty snippets.
1 parent a3180b5 commit 04da25c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

nixos/modules/system/activation/activation-script.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ let
88
sortSnippets = set: let withHeadlines = mapAttrs (a: v:
99
let entry = if isString v then noDepEntry v else v;
1010
in entry // {
11-
text = ''
11+
text = optionalString (entry.text != "") ''
1212
#### Activation script snippet ${a}:
1313
_localstatus=0
1414
${entry.text}
1515
1616
if (( _localstatus > 0 )); then
1717
printf "Activation script snippet '%s' failed (%s)\n" "${a}" "$_localstatus"
1818
fi
19+
1920
'';
20-
}) set; in textClosureMap id (withHeadlines) (attrNames withHeadlines);
21+
}) set; in concatStrings (textClosureList withHeadlines (attrNames withHeadlines));
2122

2223
path = with pkgs; map getBin
2324
[ coreutils

0 commit comments

Comments
 (0)