about summary refs log tree commit diff
path: root/nixos/modules/system/etc
diff options
context:
space:
mode:
authorTaeer Bar-Yam <taeer@bar-yam.me>2021-11-14 09:57:54 -0500
committerTaeer Bar-Yam <taeer@bar-yam.me>2021-11-15 07:03:41 -0500
commit0bef0c38f74372ca1794e800b8709b90558efba2 (patch)
tree8056bfcf9db3a0d25b68f8615013d65fd47aca3c /nixos/modules/system/etc
parent0e590c91d20efb1be7978347a2d45940a1d2fc2e (diff)
lib.modules: add mkDerivedConfig
mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b

Create config definitions with the same priority as the definition of another option.
This should be used for option definitions where one option sets the value of another as a convenience.
For instance a config file could be set with a `text` or `source` option, where text translates to a `source`
value using `mkDerivedConfig options.text (pkgs.writeText "filename.conf")`.

It takes care of setting the right priority using `mkOverride`.
Diffstat (limited to 'nixos/modules/system/etc')
-rw-r--r--nixos/modules/system/etc/etc.nix5
1 files changed, 2 insertions, 3 deletions
diff --git a/nixos/modules/system/etc/etc.nix b/nixos/modules/system/etc/etc.nix
index 225a5683e79e5..6cc8c341e6dfa 100644
--- a/nixos/modules/system/etc/etc.nix
+++ b/nixos/modules/system/etc/etc.nix
@@ -172,9 +172,8 @@ in
             target = mkDefault name;
             source = mkIf (config.text != null) (
               let name' = "etc-" + baseNameOf name;
-              in mkOverride
-                (options.text.highestPrio or lib.modules.defaultPriority)
-                (pkgs.writeText name' config.text));
+              in mkDerivedConfig options.text (pkgs.writeText name')
+            );
           };
 
         }));