@@ -15,15 +15,47 @@ let
1515 # Apply the package set function to get NixOS options.
1616 inherit (import ../package-set.nix { hackage = null; inherit pkgs pkg-def; }) options;
1717
18− # Use code from the NixOS manual to generate Docbook XML options list.
19− manual = import (pkgs.path + /nixos/doc/manual) {
20− inherit pkgs options;
21− config.meta.doc = [];
22− version = "testing";
23− revision = "testing";
24− };
25−in
26− # Convert docbook options list to markdown
27− pkgs.runCommand "options.md" {} ''
28− ${pkgs.buildPackages.pandoc}/bin/pandoc -s -f docbook -t markdown_strict ${manual.generatedSources}/options-db.xml -o $out
29− ''
18+ optionsNix = (pkgs.nixosOptionsDoc { inherit options; }).optionsNix;
19+
20+ optionsMarkdown = lib.concatStringsSep "\n" (lib.mapAttrsToList singleMarkdown optionsNix);
21+
22+ singleMarkdown = name: value: ''
23+ ## ${name}
24+
25+ ${value.description}
26+
27+ **Type**: ${value.type}
28+
29+ ${ if lib.hasAttr "default" value
30+ then ''
31+ **Default**: ${builtins.toJSON value.default}
32+ ''
33+ else "**No Default**"
34+ }
35+ ${ if value.readOnly
36+ then "**Read Only**"
37+ else ""
38+ }
39+ ${ if lib.hasAttr "example" value
40+ then ''
41+ **Example**:
42+
43+ ${builtins.toJSON value.example}
44+ ''
45+ else "**No Example**"
46+ }
47+
48+ '';
49+
50+in builtins.toFile "options.md" ''
51+Haskell.nix modules options for packages and components.
52+
53+!!! note "Generated"
54+ This documentation is generated from Nix sources in the
55+ [`modules`](https://github.com/input-output-hk/haskell.nix/tree/master/modules)
56+ subdirectory using `scripts/update-docs.nix`
57+
58+# Configuration Options
59+
60+${optionsMarkdown}
61+''