-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathutils.nix
33 lines (29 loc) · 836 Bytes
/
utils.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{ lib, systemdUtils, podmanPackage }:
let
attrsToList =
attrs:
if builtins.isAttrs attrs then
lib.mapAttrsToList (name: value: "${name}=${toString value}") attrs
else
attrs;
in
{
mkOption =
{ property, ... }@attrs:
(lib.mkOption (lib.filterAttrs (name: _: name != "property") attrs))
// {
inherit property;
};
configToProperties =
config: options:
lib.mapAttrs' (name: value: lib.nameValuePair options.${name}.property (attrsToList value)) (
lib.filterAttrs (_: value: value != null) config
);
unitConfigToText =
unitConfig:
builtins.concatStringsSep "\n\n" (
lib.mapAttrsToList (name: section: "[${name}]\n${systemdUtils.lib.attrsToSection section}") unitConfig
);
inherit (systemdUtils.unitOptions) unitOption;
inherit podmanPackage;
}