mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
generators: rewrite toSCFG
The former toSCFG implementation had several shortcomings which did not consider a few possibilities SCFG provides. Details were lined out in #7465. The new interface needs more verbosity, but reflects better the properties of the SCFG format. I also chose to use the names used in the [Specification]. [Specification]: https://git.sr.ht/~emersion/scfg#specification-draft
This commit is contained in:
parent
c9d758b500
commit
89a9fa0f3f
4 changed files with 80 additions and 90 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
home.file."toscfg-empty-result.txt".text = lib.hm.generators.toSCFG { } { };
|
||||
home.file."toscfg-empty-result.txt".text = lib.hm.generators.toSCFG { } [ ];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ dir {
|
|||
blk1 p1 "\"p2\"" {
|
||||
sub1 arg11 arg12
|
||||
sub2 arg21 arg22
|
||||
sub2 arg1 arg2
|
||||
sub3 arg31 arg32 {
|
||||
sub-sub1
|
||||
"sub sub1"
|
||||
sub-sub2 arg321 arg322
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,58 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
home.file."toscfg-example-result.txt".text = lib.hm.generators.toSCFG { } {
|
||||
dir = {
|
||||
blk1 = {
|
||||
_params = [
|
||||
home.file."toscfg-example-result.txt".text = lib.hm.generators.toSCFG { } (
|
||||
lib.singleton {
|
||||
name = "dir";
|
||||
children = lib.singleton {
|
||||
name = "blk1";
|
||||
params = [
|
||||
"p1"
|
||||
''"p2"''
|
||||
];
|
||||
sub1 = [
|
||||
"arg11"
|
||||
"arg12"
|
||||
children = [
|
||||
{
|
||||
name = "sub1";
|
||||
params = [
|
||||
"arg11"
|
||||
"arg12"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "sub2";
|
||||
params = [
|
||||
"arg21"
|
||||
"arg22"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "sub2";
|
||||
params = [
|
||||
"arg1"
|
||||
"arg2"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "sub3";
|
||||
params = [
|
||||
"arg31"
|
||||
"arg32"
|
||||
];
|
||||
children = [
|
||||
{ name = "sub sub1"; }
|
||||
{
|
||||
name = "sub-sub2";
|
||||
params = [
|
||||
"arg321"
|
||||
"arg322"
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
sub2 = [
|
||||
"arg21"
|
||||
"arg22"
|
||||
];
|
||||
sub3 = {
|
||||
_params = [
|
||||
"arg31"
|
||||
"arg32"
|
||||
];
|
||||
sub-sub1 = [ ];
|
||||
sub-sub2 = [
|
||||
"arg321"
|
||||
"arg322"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue