summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorPeter Hoeg <peter@speartail.com>2016-04-27 10:56:40 +0800
committerPeter Hoeg <peter@speartail.com>2016-09-29 17:02:10 +0800
commit1049fd49ed3e35b72db127709e7c2e661745ea8a (patch)
tree30253ce2f71801db088abd98f700eec32f7aba8c /nixos/modules/system
parentadfcc2d9531e78bf6a9e3b56e2f4fc873cb3d87b (diff)
downloadnixlib-1049fd49ed3e35b72db127709e7c2e661745ea8a.tar
nixlib-1049fd49ed3e35b72db127709e7c2e661745ea8a.tar.gz
nixlib-1049fd49ed3e35b72db127709e7c2e661745ea8a.tar.bz2
nixlib-1049fd49ed3e35b72db127709e7c2e661745ea8a.tar.lz
nixlib-1049fd49ed3e35b72db127709e7c2e661745ea8a.tar.xz
nixlib-1049fd49ed3e35b72db127709e7c2e661745ea8a.tar.zst
nixlib-1049fd49ed3e35b72db127709e7c2e661745ea8a.zip
systemd: add user target support
This allows us to define system user targets in addition to the existing
services, timers and sockets.

Furthermore, we add a top-level configuration keyword:

 - Documentation
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/systemd-unit-options.nix6
-rw-r--r--nixos/modules/system/boot/systemd.nix15
2 files changed, 19 insertions, 2 deletions
diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix
index f4892244de47..731b1701e00d 100644
--- a/nixos/modules/system/boot/systemd-unit-options.nix
+++ b/nixos/modules/system/boot/systemd-unit-options.nix
@@ -77,6 +77,12 @@ in rec {
       description = "Description of this unit used in systemd messages and progress indicators.";
     };
 
+    documentation = mkOption {
+      default = [];
+      type = types.listOf types.str;
+      description = "A list of URIs referencing documentation for this unit or its configuration.";
+    };
+
     requires = mkOption {
       default = [];
       type = types.listOf types.str;
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index b724995bb1fc..b2a80a7e395a 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;
         };
     };
@@ -630,6 +634,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;
@@ -758,6 +768,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