mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
nixos/lib: systemd definition files function
Add a re-usable function that converts an attrset to a directory containing systemd definition files.
This commit is contained in:
parent
906f999a2f
commit
a662dc8b73
3 changed files with 27 additions and 29 deletions
|
@ -443,4 +443,21 @@ in rec {
|
|||
${attrsToSection def.sliceConfig}
|
||||
'';
|
||||
};
|
||||
|
||||
# Create a directory that contains systemd definition files from an attrset
|
||||
# that contains the file names as keys and the content as values. The values
|
||||
# in that attrset are determined by the supplied format.
|
||||
definitions = directoryName: format: definitionAttrs:
|
||||
let
|
||||
listOfDefinitions = lib.mapAttrsToList
|
||||
(name: format.generate "${name}.conf")
|
||||
definitionAttrs;
|
||||
in
|
||||
pkgs.runCommand directoryName { } ''
|
||||
mkdir -p $out
|
||||
${(lib.concatStringsSep "\n"
|
||||
(map (pkg: "cp ${pkg} $out/${pkg.name}") listOfDefinitions)
|
||||
)}
|
||||
'';
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue