about summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorWill Fancher <elvishjerricco@gmail.com>2022-03-19 04:02:39 -0400
committerWill Fancher <elvishjerricco@gmail.com>2022-03-21 10:25:27 -0400
commit52c98fc3e9b593f1b98caeb00864f884e897866f (patch)
tree84998004d43e48bb57fc148fdc6cb98a8ac0673e /nixos/lib
parent397b8257a0f926c518a01dd20d2911945a649743 (diff)
nixos: systemd: Split unit types into separate module
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/systemd-types.nix29
-rw-r--r--nixos/lib/utils.nix1
2 files changed, 30 insertions, 0 deletions
diff --git a/nixos/lib/systemd-types.nix b/nixos/lib/systemd-types.nix
new file mode 100644
index 0000000000000..a7a324f187c28
--- /dev/null
+++ b/nixos/lib/systemd-types.nix
@@ -0,0 +1,29 @@
+{ lib, systemdUtils }:
+
+with systemdUtils.lib;
+with systemdUtils.unitOptions;
+with lib;
+
+rec {
+  units = with types;
+    attrsOf (submodule ({ name, config, ... }: {
+      options = concreteUnitOptions;
+      config = { unit = mkDefault (systemdUtils.lib.makeUnit name config); };
+    }));
+
+  services = with types; attrsOf (submodule [ { options = serviceOptions; } unitConfig serviceConfig ]);
+
+  targets = with types; attrsOf (submodule [ { options = targetOptions; } unitConfig ]);
+
+  sockets = with types; attrsOf (submodule [ { options = socketOptions; } unitConfig ]);
+
+  timers = with types; attrsOf (submodule [ { options = timerOptions; } unitConfig ]);
+
+  paths = with types; attrsOf (submodule [ { options = pathOptions; } unitConfig ]);
+
+  slices = with types; attrsOf (submodule [ { options = sliceOptions; } unitConfig ]);
+
+  mounts = with types; listOf (submodule [ { options = mountOptions; } unitConfig mountConfig ]);
+
+  automounts = with types; listOf (submodule [ { options = automountOptions; } unitConfig automountConfig ]);
+}
diff --git a/nixos/lib/utils.nix b/nixos/lib/utils.nix
index ae68c3920c5bb..80341dd48fcd5 100644
--- a/nixos/lib/utils.nix
+++ b/nixos/lib/utils.nix
@@ -197,5 +197,6 @@ rec {
   systemdUtils = {
     lib = import ./systemd-lib.nix { inherit lib config pkgs; };
     unitOptions = import ./systemd-unit-options.nix { inherit lib systemdUtils; };
+    types = import ./systemd-types.nix { inherit lib systemdUtils; };
   };
 }