@@ -88,8 +88,49 @@ let
8888 # Convert the list of options into an XML file.
8989 optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList);
9090
91+ optionsNix = builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList);
92+
93+ # TODO: declarations: link to github
94+ singleAsciiDoc = name: value: ''
95+ == ${name}
96+
97+ ${value.description}
98+
99+ [discrete]
100+ === details
101+
102+ Type:: ${value.type}
103+ ${ if lib.hasAttr "default" value
104+ then ''
105+ Default::
106+ +
107+ ----
108+ ${builtins.toJSON value.default}
109+ ----
110+ ''
111+ else "No Default:: {blank}"
112+ }
113+ ${ if value.readOnly
114+ then "Read Only:: {blank}"
115+ else ""
116+ }
117+ ${ if lib.hasAttr "example" value
118+ then ''
119+ Example::
120+ +
121+ ----
122+ ${builtins.toJSON value.example}
123+ ----
124+ ''
125+ else "No Example:: {blank}"
126+ }
127+ '';
128+
91129in rec {
92− # The NixOS options in JSON format.
130+ inherit optionsNix;
131+
132+ optionsAsciiDoc = lib.concatStringsSep "\n" (lib.mapAttrsToList singleAsciiDoc optionsNix);
133+
93134 optionsJSON = pkgs.runCommand "options.json"
94135 { meta.description = "List of NixOS options in JSON format";
95136 }
@@ -98,9 +139,7 @@ in rec {
98139 dst=$out/share/doc/nixos
99140 mkdir -p $dst
100141
101− cp ${builtins.toFile "options.json" (builtins.unsafeDiscardStringContext (builtins.toJSON
102− (builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList))))
103− } $dst/options.json
142+ cp ${builtins.toFile "options.json" (builtins.unsafeDiscardStringContext (builtins.toJSON optionsNix))} $dst/options.json
104143
105144 mkdir -p $out/nix-support
106145 echo "file json $dst/options.json" >> $out/nix-support/hydra-build-products