summary refs log tree commit diff
path: root/nixos/modules/system/boot/systemd-unit-options.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-17 23:35:05 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-17 23:35:05 +0200
commit073351a5cfdcf844e05f3ce0e03df686769a7c43 (patch)
treebe5a7f9187f7723413ecc37a3195db27a6cac1b7 /nixos/modules/system/boot/systemd-unit-options.nix
parent2ad6933a22fd0f834f4abf1766f56c797c26991c (diff)
downloadnixlib-073351a5cfdcf844e05f3ce0e03df686769a7c43.tar
nixlib-073351a5cfdcf844e05f3ce0e03df686769a7c43.tar.gz
nixlib-073351a5cfdcf844e05f3ce0e03df686769a7c43.tar.bz2
nixlib-073351a5cfdcf844e05f3ce0e03df686769a7c43.tar.lz
nixlib-073351a5cfdcf844e05f3ce0e03df686769a7c43.tar.xz
nixlib-073351a5cfdcf844e05f3ce0e03df686769a7c43.tar.zst
nixlib-073351a5cfdcf844e05f3ce0e03df686769a7c43.zip
Refactor unit option declarations
This gets rid of some duplication.
Diffstat (limited to 'nixos/modules/system/boot/systemd-unit-options.nix')
-rw-r--r--nixos/modules/system/boot/systemd-unit-options.nix59
1 files changed, 40 insertions, 19 deletions
diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix
index a16263b390d7..a6183c47eb1b 100644
--- a/nixos/modules/system/boot/systemd-unit-options.nix
+++ b/nixos/modules/system/boot/systemd-unit-options.nix
@@ -28,7 +28,7 @@ let
 
 in rec {
 
-  unitOptions = {
+  sharedOptions = {
 
     enable = mkOption {
       default = true;
@@ -41,6 +41,37 @@ in rec {
       '';
     };
 
+    requiredBy = mkOption {
+      default = [];
+      type = types.listOf types.string;
+      description = "Units that require (i.e. depend on and need to go down with) this unit.";
+    };
+
+    wantedBy = mkOption {
+      default = [];
+      type = types.listOf types.string;
+      description = "Units that want (i.e. depend on) this unit.";
+    };
+
+  };
+
+  concreteUnitOptions = sharedOptions // {
+
+    text = mkOption {
+      type = types.nullOr types.str;
+      default = null;
+      description = "Text of this systemd unit.";
+    };
+
+    unit = mkOption {
+      internal = true;
+      description = "The generated unit.";
+    };
+
+  };
+
+  commonUnitOptions = sharedOptions // {
+
     description = mkOption {
       default = "";
       type = types.str;
@@ -109,18 +140,6 @@ in rec {
       '';
     };
 
-    requiredBy = mkOption {
-      default = [];
-      type = types.listOf types.str;
-      description = "Units that require (i.e. depend on and need to go down with) this unit.";
-    };
-
-    wantedBy = mkOption {
-      default = [];
-      type = types.listOf types.str;
-      description = "Units that want (i.e. depend on) this unit.";
-    };
-
     unitConfig = mkOption {
       default = {};
       example = { RequiresMountsFor = "/data"; };
@@ -146,7 +165,7 @@ in rec {
   };
 
 
-  serviceOptions = unitOptions // {
+  serviceOptions = commonUnitOptions // {
 
     environment = mkOption {
       default = {};
@@ -280,7 +299,7 @@ in rec {
   };
 
 
-  socketOptions = unitOptions // {
+  socketOptions = commonUnitOptions // {
 
     listenStreams = mkOption {
       default = [];
@@ -307,7 +326,7 @@ in rec {
   };
 
 
-  timerOptions = unitOptions // {
+  timerOptions = commonUnitOptions // {
 
     timerConfig = mkOption {
       default = {};
@@ -326,7 +345,7 @@ in rec {
   };
 
 
-  pathOptions = unitOptions // {
+  pathOptions = commonUnitOptions // {
 
     pathConfig = mkOption {
       default = {};
@@ -343,7 +362,7 @@ in rec {
   };
 
 
-  mountOptions = unitOptions // {
+  mountOptions = commonUnitOptions // {
 
     what = mkOption {
       example = "/dev/sda1";
@@ -387,7 +406,7 @@ in rec {
     };
   };
 
-  automountOptions = unitOptions // {
+  automountOptions = commonUnitOptions // {
 
     where = mkOption {
       example = "/mnt";
@@ -411,4 +430,6 @@ in rec {
     };
   };
 
+  targetOptions = commonUnitOptions;
+
 }