Skip to content

Commit

Permalink
doc: document pkgs.formats.kdl
Browse files Browse the repository at this point in the history
  • Loading branch information
feathecutie committed Jul 31, 2024
1 parent db8a084 commit 689d36e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions nixos/doc/manual/development/settings-options.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,53 @@ have a predefined type and string generator already declared under
and returning a set with TOML-specific attributes `type` and
`generate` as specified [below](#pkgs-formats-result).

`pkgs.formats.kdl` { }

: A function taking an empty attribute set (for future extensibility)
and returning a set with [KDL](https://kdl.dev/)-specific attributes `type`,
`lib` and `generate` as specified [below](#pkgs-formats-result).

`lib` is a set containing a single function `node`, which is a helper
function indended to facilitate generating the required structure for pkgs.formats.kdl
in an ergonomic way.

Its signature is as follows:

```nix
identifier: arguments: properties: children: { inherit identifier arguments properties children; };
```

This allows writing the KDL node

```kdl
name "arg1" "arg2" prop=1 {
child
}
```

as

```nix
(node "name" [ "arg1" "arg2" ] { prop = 1; } [
(node "child" [ ] { } [ ])
])
```

instead of

```nix
{
identifier = "name";
arguments = [ "arg1" "arg2" ];
properties = { prop = 1; };
children = [
{
identifier = "child";
}
];
}
```

`pkgs.formats.elixirConf { elixir ? pkgs.elixir }`

: A function taking an attribute set with values
Expand Down

0 comments on commit 689d36e

Please sign in to comment.