summary refs log tree commit diff
path: root/modules/system/boot/systemd.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-01 18:58:11 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-01 18:58:11 -0400
commit2cf5e3cb6640ae634c5d7060d0ff6fa3b647ce70 (patch)
tree0a2fed1eeebcac7b354f5431671bee745d144aa1 /modules/system/boot/systemd.nix
parentca13a913d9f128616b79df971d76e5dd12132a53 (diff)
downloadnixpkgs-2cf5e3cb6640ae634c5d7060d0ff6fa3b647ce70.tar
nixpkgs-2cf5e3cb6640ae634c5d7060d0ff6fa3b647ce70.tar.gz
nixpkgs-2cf5e3cb6640ae634c5d7060d0ff6fa3b647ce70.tar.bz2
nixpkgs-2cf5e3cb6640ae634c5d7060d0ff6fa3b647ce70.tar.lz
nixpkgs-2cf5e3cb6640ae634c5d7060d0ff6fa3b647ce70.tar.xz
nixpkgs-2cf5e3cb6640ae634c5d7060d0ff6fa3b647ce70.tar.zst
nixpkgs-2cf5e3cb6640ae634c5d7060d0ff6fa3b647ce70.zip
Add options ‘boot.systemd.targets’ and ‘boot.systemd.sockets’
Diffstat (limited to 'modules/system/boot/systemd.nix')
-rw-r--r--modules/system/boot/systemd.nix54
1 files changed, 51 insertions, 3 deletions
diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix
index bb2ea087c21..23751e2104a 100644
--- a/modules/system/boot/systemd.nix
+++ b/modules/system/boot/systemd.nix
@@ -202,9 +202,17 @@ let
         (if isList value then value else [value]))
         as));
 
-  serviceToUnit = name: def:
+  targetToUnit = name: def:
     { inherit (def) wantedBy;
+      text =
+        ''
+          [Unit]
+          ${attrsToSection def.unitConfig}
+        '';
+    };
 
+  serviceToUnit = name: def:
+    { inherit (def) wantedBy;
       text =
         ''
           [Unit]
@@ -240,6 +248,18 @@ let
         '';
     };
 
+  socketToUnit = name: def:
+    { inherit (def) wantedBy;
+      text =
+        ''
+          [Unit]
+          ${attrsToSection def.unitConfig}
+
+          [Socket]
+          ${attrsToSection def.socketConfig}
+        '';
+    };
+
   nixosUnits = mapAttrsToList makeUnit cfg.units;
 
   units = pkgs.runCommand "units" { preferLocalBuild = true; }
@@ -319,11 +339,37 @@ in
       description = "Packages providing systemd units.";
     };
 
+    boot.systemd.targets = mkOption {
+      default = {};
+      type = types.attrsOf types.optionSet;
+      options = unitOptions;
+      description = "Definition of systemd target units.";
+    };
+
     boot.systemd.services = mkOption {
       default = {};
       type = types.attrsOf types.optionSet;
       options = [ serviceOptions serviceConfig ];
-      description = "Definition of systemd services.";
+      description = "Definition of systemd service units.";
+    };
+
+    boot.systemd.sockets = mkOption {
+      default = {};
+      type = types.attrsOf types.optionSet;
+      options = unitOptions // {
+        socketConfig = mkOption {
+          default = {};
+          example = { ListenStream = "/run/my-socket"; };
+          type = types.attrs;
+          description = ''
+            Each attribute in this set specifies an option in the
+            <literal>[Socket]</literal> section of the unit.  See
+            <citerefentry><refentrytitle>systemd.socket</refentrytitle>
+            <manvolnum>5</manvolnum></citerefentry> for details.
+          '';
+        };
+      };
+      description = "Definition of systemd socket units.";
     };
 
     boot.systemd.defaultUnit = mkOption {
@@ -385,7 +431,9 @@ in
     boot.systemd.units =
       { "rescue.service".text = rescueService; }
       // { "fs.target" = { text = fsTarget; wantedBy = [ "multi-user.target" ]; }; }
-      // mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.services;
+      // mapAttrs' (n: v: nameValuePair "${n}.target" (targetToUnit n v)) cfg.targets
+      // mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.services
+      // mapAttrs' (n: v: nameValuePair "${n}.socket" (socketToUnit n v)) cfg.sockets;
 
   };