etc module: make .text and .source the same priority

Before this change, one could set environment.etc.*.text and .source.
.source would always take precedence, regardless of the priorities set.
This change means that if, for instance, .text is set with mkForce but
.source is set normally, the .text content will be the one to take
effect. If they are set with the same priority they will conflict.
This commit is contained in:
Taeer Bar-Yam 2021-11-10 22:01:31 -05:00
parent add99c5c4e
commit 0e590c91d2

View file

@ -85,7 +85,7 @@ in
'';
type = with types; attrsOf (submodule (
{ name, config, ... }:
{ name, config, options, ... }:
{ options = {
enable = mkOption {
@ -172,7 +172,9 @@ in
target = mkDefault name;
source = mkIf (config.text != null) (
let name' = "etc-" + baseNameOf name;
in mkDefault (pkgs.writeText name' config.text));
in mkOverride
(options.text.highestPrio or lib.modules.defaultPriority)
(pkgs.writeText name' config.text));
};
}));