From acf813cadc33b339cd1d575aba44fdc283717dd7 Mon Sep 17 00:00:00 2001
From: Robert Helgesson <robert@rycee.net>
Date: Thu, 29 Jun 2017 01:06:08 +0200
Subject: [PATCH] systemd: add support for socket units

---
 modules/systemd.nix | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/modules/systemd.nix b/modules/systemd.nix
index ef68b6d6..edc89ab0 100644
--- a/modules/systemd.nix
+++ b/modules/systemd.nix
@@ -7,7 +7,10 @@ let
 
   cfg = config.systemd.user;
 
-  enabled = cfg.services != {} || cfg.targets != {} || cfg.timers != {};
+  enabled = cfg.services != {}
+      || cfg.sockets != {}
+      || cfg.targets != {}
+      || cfg.timers != {};
 
   toSystemdIni = (import lib/generators.nix).toINI {
     mkKeyValue = key: value:
@@ -50,6 +53,12 @@ in
         description = "Definition of systemd per-user service units.";
       };
 
+      sockets = mkOption {
+        default = {};
+        type = types.attrs;
+        description = "Definition of systemd per-user sockets";
+      };
+
       targets = mkOption {
         default = {};
         type = types.attrs;
@@ -72,7 +81,9 @@ in
           message =
             let
               names = concatStringsSep ", " (
-                  attrNames (cfg.services // cfg.targets // cfg.timers)
+                  attrNames (
+                      cfg.services // cfg.sockets // cfg.targets // cfg.timers
+                  )
               );
             in
               "Must use Linux for modules that require systemd: " + names;
@@ -87,6 +98,8 @@ in
         listToAttrs (
           (buildServices "service" cfg.services)
           ++
+          (buildServices "socket" cfg.sockets)
+          ++
           (buildServices "target" cfg.targets)
           ++
           (buildServices "timer" cfg.timers)