nixos/unitOption: remove unnecessary definition filtering (#412468)

This commit is contained in:
Johannes Kirschbauer 2025-06-02 18:37:26 +02:00 committed by GitHub
commit ac5a33bdab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 11 deletions

View file

@ -15,7 +15,6 @@ let
inherit (lib) inherit (lib)
any any
concatMap concatMap
filterOverrides
isList isList
literalExpression literalExpression
mergeEqualOption mergeEqualOption
@ -56,13 +55,10 @@ rec {
name = "systemd option"; name = "systemd option";
merge = merge =
loc: defs: loc: defs:
let if any (def: isList def.value) defs then
defs' = filterOverrides defs; concatMap (def: toList def.value) defs
in
if any (def: isList def.value) defs' then
concatMap (def: toList def.value) defs'
else else
mergeEqualOption loc defs'; mergeEqualOption loc defs;
}; };
sharedOptions = { sharedOptions = {

View file

@ -9,7 +9,7 @@ let
checkType = x: lib.isBool x || lib.isString x || lib.isInt x || x == null; checkType = x: lib.isBool x || lib.isString x || lib.isInt x || x == null;
in in
checkType val || (val._type or "" == "override" && checkType val.content); checkType val || (val._type or "" == "override" && checkType val.content);
merge = loc: defs: lib.mergeOneOption loc (lib.filterOverrides defs); merge = loc: defs: lib.mergeOneOption loc defs;
}; };
in in
@ -22,9 +22,7 @@ in
type = type =
let let
highestValueType = lib.types.ints.unsigned // { highestValueType = lib.types.ints.unsigned // {
merge = merge = loc: defs: lib.foldl (a: b: if b.value == null then null else lib.max a b.value) 0 defs;
loc: defs:
lib.foldl (a: b: if b.value == null then null else lib.max a b.value) 0 (lib.filterOverrides defs);
}; };
in in
lib.types.submodule { lib.types.submodule {