types.attrsOf: Use mergeDefinitions to handle each element

This simplifes typechecking and allows properties to be used inside of
the attribute sets.

This fixes the empty synergy-client and synergy-server services
previously generated on systems with synergy disabled.
This commit is contained in:
Shea Levy 2014-05-01 18:13:06 -04:00 committed by Nicolas B. Pierron
parent e4bc2592f3
commit 8737d1783f

View File

@ -126,12 +126,16 @@ in rec {
attrsOf = elemType: mkOptionType {
name = "attribute set of ${elemType.name}s";
check = x: isAttrs x && all elemType.check (attrValues x);
check = isAttrs;
merge = loc: defs:
zipAttrsWith (name: elemType.merge (loc ++ [name]))
mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
let
inherit (mergeDefinitions (loc ++ [name]) elemType defs)
defsFinal mergedValue;
in if defsFinal == [] then {} else { value = mergedValue; })
# Push down position info.
(map (def: listToAttrs (mapAttrsToList (n: def':
{ name = n; value = { inherit (def) file; value = def'; }; }) def.value)) defs);
{ name = n; value = { inherit (def) file; value = def'; }; }) def.value)) defs)));
getSubOptions = prefix: elemType.getSubOptions (prefix ++ ["<name>"]);
getSubModules = elemType.getSubModules;
substSubModules = m: attrsOf (elemType.substSubModules m);