...with some basic optional persistence and without having to rebuild images for every app nix run -f . pkgs.uvms -- --persist-home librewolf alacritty --run librewolf --run alacritty
39 lines
589 B
Nix
39 lines
589 B
Nix
{
|
|
lib,
|
|
runCommand,
|
|
writeShellScriptBin,
|
|
}:
|
|
{
|
|
name,
|
|
prefix ? "10-all-",
|
|
dirs ? [
|
|
"service"
|
|
"mount"
|
|
"socket"
|
|
"timer"
|
|
"target"
|
|
],
|
|
|
|
dropinText ? null,
|
|
extraCommands ? "",
|
|
...
|
|
}@args:
|
|
|
|
runCommand "${name}-dropin"
|
|
(
|
|
lib.removeAttrs args [
|
|
"name"
|
|
]
|
|
// {
|
|
inherit dirs dropinText extraCommands;
|
|
}
|
|
)
|
|
''
|
|
set -euo pipefail
|
|
root=$out/lib/systemd/system
|
|
for dir in $dirs ; do
|
|
mkdir -p "$root/$dir".d
|
|
printf "%s" "$dropinText" > "$root/$dir.d/${prefix}${name}.conf"
|
|
done
|
|
runHook extraCommands
|
|
''
|