From 89155dbc01e899a08151e50c01e82ad469c5ad59 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Thu, 17 Apr 2014 12:03:04 +0200
Subject: [PATCH] systemd: Enable user systemd instances

---
 nixos/modules/system/boot/systemd.nix | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 30cff8c8ab2d..a35c3224db2a 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -727,5 +727,17 @@ in
         })
         (filterAttrs (name: service: service.startAt != "") cfg.services);
 
+    # Provide the systemd-user PAM service, required to run systemd
+    # user instances.
+    security.pam.services.systemd-user =
+      { # Ensure that pam_systemd gets included. This is special-cased
+        # in systemd to provide XDG_RUNTIME_DIR.
+        startSession = true;
+      };
+
+    # Provide systemd user units. FIXME: Should make this definable,
+    # just like the system units.
+    environment.etc."systemd/user".source = "${systemd}/example/systemd/user";
+
   };
 }