diff options
author | Domen Kožar <domen@dev.si> | 2019-08-13 12:20:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-13 12:20:18 +0200 |
commit | 0047672d58ad13bd0a60e9114b6c91858c34b2a8 (patch) | |
tree | 3a850478ffbf7e03907be81d68afe1db150fec2b | |
parent | 7bad92935d12845f31e54f3dc5bafdca3f058ad1 (diff) | |
parent | dcd50c0ea03f3a5b028038e06b6b2e1ce7423404 (diff) | |
download | nixlib-0047672d58ad13bd0a60e9114b6c91858c34b2a8.tar nixlib-0047672d58ad13bd0a60e9114b6c91858c34b2a8.tar.gz nixlib-0047672d58ad13bd0a60e9114b6c91858c34b2a8.tar.bz2 nixlib-0047672d58ad13bd0a60e9114b6c91858c34b2a8.tar.lz nixlib-0047672d58ad13bd0a60e9114b6c91858c34b2a8.tar.xz nixlib-0047672d58ad13bd0a60e9114b6c91858c34b2a8.tar.zst nixlib-0047672d58ad13bd0a60e9114b6c91858c34b2a8.zip |
Merge pull request #66436 from domenkozar/nixos-options-doc-nix
make-options-doc: expose Nix set and add asciidoc variant
-rw-r--r-- | nixos/lib/make-options-doc/default.nix | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/nixos/lib/make-options-doc/default.nix b/nixos/lib/make-options-doc/default.nix index c22c7500335d..88e052106a28 100644 --- a/nixos/lib/make-options-doc/default.nix +++ b/nixos/lib/make-options-doc/default.nix @@ -88,8 +88,49 @@ let # Convert the list of options into an XML file. optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList); + optionsNix = builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList); + + # TODO: declarations: link to github + singleAsciiDoc = name: value: '' + == ${name} + + ${value.description} + + [discrete] + === details + + Type:: ${value.type} + ${ if lib.hasAttr "default" value + then '' + Default:: + + + ---- + ${builtins.toJSON value.default} + ---- + '' + else "No Default:: {blank}" + } + ${ if value.readOnly + then "Read Only:: {blank}" + else "" + } + ${ if lib.hasAttr "example" value + then '' + Example:: + + + ---- + ${builtins.toJSON value.example} + ---- + '' + else "No Example:: {blank}" + } + ''; + in rec { - # The NixOS options in JSON format. + inherit optionsNix; + + optionsAsciiDoc = lib.concatStringsSep "\n" (lib.mapAttrsToList singleAsciiDoc optionsNix); + optionsJSON = pkgs.runCommand "options.json" { meta.description = "List of NixOS options in JSON format"; } @@ -98,9 +139,7 @@ in rec { dst=$out/share/doc/nixos mkdir -p $dst - cp ${builtins.toFile "options.json" (builtins.unsafeDiscardStringContext (builtins.toJSON - (builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList)))) - } $dst/options.json + cp ${builtins.toFile "options.json" (builtins.unsafeDiscardStringContext (builtins.toJSON optionsNix))} $dst/options.json mkdir -p $out/nix-support echo "file json $dst/options.json" >> $out/nix-support/hydra-build-products |