feat(helpers/text): add support for unordered parts
This commit is contained in:
parent
a160c6d5dd
commit
5f1536d44b
1 changed files with 12 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
|
mapAttrsToList
|
||||||
optional
|
optional
|
||||||
concatStrings
|
concatStrings
|
||||||
flatten
|
flatten
|
||||||
|
@ -31,7 +32,10 @@ let
|
||||||
type = str;
|
type = str;
|
||||||
default = "";
|
default = "";
|
||||||
};
|
};
|
||||||
order = mkOption { type = listOf str; };
|
order = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
parts = mkOption { type = lazyAttrsOf textType; };
|
parts = mkOption { type = lazyAttrsOf textType; };
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
@ -55,10 +59,13 @@ let
|
||||||
]
|
]
|
||||||
(optional (value.description != "") value.description)
|
(optional (value.description != "") value.description)
|
||||||
(map (mkListFromAttrs (prefix + 1)) (
|
(map (mkListFromAttrs (prefix + 1)) (
|
||||||
map (x: {
|
if value.order == [ ] then
|
||||||
name = x;
|
mapAttrsToList (name: value: { inherit name value; }) value.parts
|
||||||
value = flip getAttr value.parts x;
|
else
|
||||||
}) value.order
|
map (x: {
|
||||||
|
name = x;
|
||||||
|
value = flip getAttr value.parts x;
|
||||||
|
}) value.order
|
||||||
))
|
))
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue