Last active
May 29, 2023 19:18
-
-
Save Quelklef/48291d934d2c2a3606a7b20207ed428b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
environment.etc = { | |
# Utility scripts. Must be manually symlinked into /root | |
"my-scripts".source = let | |
scripts = [ | |
{ | |
"script-name.sh" = '' | |
echo 'script content'; | |
''; | |
} | |
( | |
let condition = false; in | |
if condition | |
then { "other-script.sh" = "echo 'other content'"; } | |
else null # gets excluded | |
) | |
]; | |
in pkgs.stdenv.mkDerivation { | |
name = "etc-util-scripts"; | |
dontUnpack = true; | |
installPhase = '' | |
mkdir -p $out | |
${ let inherit (pkgs.lib) trivial attrsets strings lists; in | |
trivial.pipe scripts [ | |
(lists.filter (x: x != null)) | |
(lists.foldl trivial.mergeAttrs {}) | |
(attrsets.mapAttrsToList | |
(name: text: "cp ${pkgs.writeScript name text} $out/${name}\n")) | |
strings.concatStrings | |
] } | |
''; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment