feat(helpers/text): add support for unordered parts
This commit is contained in:
parent
2c77ff76ba
commit
9420f4b84c
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,6 +59,9 @@ let
|
||||||
]
|
]
|
||||||
(optional (value.description != "") value.description)
|
(optional (value.description != "") value.description)
|
||||||
(map (mkListFromAttrs (prefix + 1)) (
|
(map (mkListFromAttrs (prefix + 1)) (
|
||||||
|
if value.order == [ ] then
|
||||||
|
mapAttrsToList (name: value: { inherit name value; }) value.parts
|
||||||
|
else
|
||||||
map (x: {
|
map (x: {
|
||||||
name = x;
|
name = x;
|
||||||
value = flip getAttr value.parts x;
|
value = flip getAttr value.parts x;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue