summary refs log tree commit diff
path: root/nixos/modules/system/boot/systemd.nix
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@higgsboson.tk>2016-10-03 23:10:18 +0200
committerGitHub <noreply@github.com>2016-10-03 23:10:18 +0200
commite5c6f35a4941d89051791478216aa1e1a87d2f25 (patch)
tree498d9517c989a7dd912e487bb9cfca824512ca88 /nixos/modules/system/boot/systemd.nix
parentf12fcfebe252dd603d04edadf929a3f8de73d2e6 (diff)
parent1049fd49ed3e35b72db127709e7c2e661745ea8a (diff)
downloadnixlib-e5c6f35a4941d89051791478216aa1e1a87d2f25.tar
nixlib-e5c6f35a4941d89051791478216aa1e1a87d2f25.tar.gz
nixlib-e5c6f35a4941d89051791478216aa1e1a87d2f25.tar.bz2
nixlib-e5c6f35a4941d89051791478216aa1e1a87d2f25.tar.lz
nixlib-e5c6f35a4941d89051791478216aa1e1a87d2f25.tar.xz
nixlib-e5c6f35a4941d89051791478216aa1e1a87d2f25.tar.zst
nixlib-e5c6f35a4941d89051791478216aa1e1a87d2f25.zip
Merge pull request #19069 from peterhoeg/targets
systemd: add user target support
Diffstat (limited to 'nixos/modules/system/boot/systemd.nix')
-rw-r--r--nixos/modules/system/boot/systemd.nix15
1 files changed, 13 insertions, 2 deletions
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 4a59d6474808..d44c2e234b0f 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -185,6 +185,8 @@ let
       "timers.target"
     ];
 
+  boolToString = value: if value then "yes" else "no";
+
   makeJobScript = name: text:
     let mkScriptName =  s: (replaceChars [ "\\" ] [ "-" ] (shellEscape s) );
         x = pkgs.writeTextFile { name = "unit-script"; executable = true; destination = "/bin/${mkScriptName name}"; inherit text; };
@@ -212,8 +214,10 @@ let
         // optionalAttrs (config.restartTriggers != [])
           { X-Restart-Triggers = toString config.restartTriggers; }
         // optionalAttrs (config.description != "") {
-          Description = config.description;
-        } // optionalAttrs (config.onFailure != []) {
+          Description = config.description; }
+        // optionalAttrs (config.documentation != []) {
+          Documentation = toString config.documentation; }
+        // optionalAttrs (config.onFailure != []) {
           OnFailure = toString config.onFailure;
         };
     };
@@ -620,6 +624,12 @@ in
       description = "Definition of systemd per-user socket units.";
     };
 
+    systemd.user.targets = mkOption {
+      default = {};
+      type = with types; attrsOf (submodule [ { options = targetOptions; } unitConfig] );
+      description = "Definition of systemd per-user target units.";
+    };
+
     systemd.additionalUpstreamSystemUnits = mkOption {
       default = [ ];
       type = types.listOf types.str;
@@ -748,6 +758,7 @@ in
     systemd.user.units =
          mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.user.services
       // mapAttrs' (n: v: nameValuePair "${n}.socket"  (socketToUnit  n v)) cfg.user.sockets
+      // mapAttrs' (n: v: nameValuePair "${n}.target"  (targetToUnit  n v)) cfg.user.targets
       // mapAttrs' (n: v: nameValuePair "${n}.timer"   (timerToUnit   n v)) cfg.user.timers;
 
     system.requiredKernelConfig = map config.lib.kernelConfig.isEnabled