forked from input-output-hk/haskell.nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions-doc.nix
61 lines (48 loc) · 1.42 KB
/
options-doc.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{ pkgs ? import <nixpkgs> {}
, lib ? pkgs.lib
}:
let
# Provide a dummy pkg-def for the package set function
pkg-def = hackage: {
packages = {};
compiler = {
version = "";
nix-name = "";
packages = {};
};
};
# Apply the package set function to get NixOS options.
inherit (import ../package-set.nix { hackage = null; inherit pkgs pkg-def; }) options;
optionsNix = (pkgs.nixosOptionsDoc { inherit options; }).optionsNix;
optionsMarkdown = lib.concatStringsSep "\n" (lib.mapAttrsToList singleMarkdown optionsNix);
singleMarkdown = name: value: ''
## ${name}
${lib.optionalString (value.description != null) value.description}
**Type**: ${value.type}
${ if lib.hasAttr "default" value
then ''
**Default**: ${builtins.toJSON value.default}
''
else "**No Default**"
}
${ if value.readOnly
then "**Read Only**"
else ""
}
${ if lib.hasAttr "example" value
then ''
**Example**:
${builtins.toJSON value.example}
''
else "**No Example**"
}
'';
in builtins.toFile "options.md" ''
Haskell.nix modules options for packages and components.
!!! note "Generated"
This documentation is generated from Nix sources in the
[`modules`](https://github.com/input-output-hk/haskell.nix/tree/master/modules)
subdirectory using `scripts/update-docs.nix`
# Configuration Options
${optionsMarkdown}
''