summary refs log tree commit diff
path: root/lib/options.nix
diff options
context:
space:
mode:
authorJan Malakhovski <oxij@oxij.org>2016-04-20 21:57:33 +0000
committerJan Malakhovski <oxij@oxij.org>2018-02-09 19:51:06 +0000
commit660806066abc4a64ac44b53b2b1a20f5ab4d920b (patch)
tree509656f0b651896de5205746b3d42298f8a6c58b /lib/options.nix
parenta7d75ab6489dc5834e8402db374b4d0f1e774d53 (diff)
downloadnixpkgs-660806066abc4a64ac44b53b2b1a20f5ab4d920b.tar
nixpkgs-660806066abc4a64ac44b53b2b1a20f5ab4d920b.tar.gz
nixpkgs-660806066abc4a64ac44b53b2b1a20f5ab4d920b.tar.bz2
nixpkgs-660806066abc4a64ac44b53b2b1a20f5ab4d920b.tar.lz
nixpkgs-660806066abc4a64ac44b53b2b1a20f5ab4d920b.tar.xz
nixpkgs-660806066abc4a64ac44b53b2b1a20f5ab4d920b.tar.zst
nixpkgs-660806066abc4a64ac44b53b2b1a20f5ab4d920b.zip
nixos, lib: implement relatedPackages option
This allows one to specify "related packages" in NixOS that get rendered into
the configuration.nix(5) man page. The interface philosophy is pretty much
stolen from TeX bibliography.

See the next several commits for examples.
Diffstat (limited to 'lib/options.nix')
-rw-r--r--lib/options.nix9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/options.nix b/lib/options.nix
index 769d3cc5572..e10c86dd506 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -14,6 +14,7 @@ rec {
     , defaultText ? null # Textual representation of the default, for in the manual.
     , example ? null # Example value used in the manual.
     , description ? null # String describing the option.
+    , relatedPackages ? null # Related packages used in the manual (see `genRelatedPackages` in ../nixos/doc/manual/default.nix).
     , type ? null # Option type, providing type-checking and value merging.
     , apply ? null # Function that converts the option value to something else.
     , internal ? null # Whether the option is for NixOS developers only.
@@ -76,7 +77,6 @@ rec {
   getValues = map (x: x.value);
   getFiles = map (x: x.file);
 
-
   # Generate documentation template from the list of option declaration like
   # the set generated with filterOptionSets.
   optionAttrSetToDocList = optionAttrSetToDocList' [];
@@ -93,9 +93,10 @@ rec {
           readOnly = opt.readOnly or false;
           type = opt.type.description or null;
         }
-        // (if opt ? example then { example = scrubOptionValue opt.example; } else {})
-        // (if opt ? default then { default = scrubOptionValue opt.default; } else {})
-        // (if opt ? defaultText then { default = opt.defaultText; } else {});
+        // optionalAttrs (opt ? example) { example = scrubOptionValue opt.example; }
+        // optionalAttrs (opt ? default) { default = scrubOptionValue opt.default; }
+        // optionalAttrs (opt ? defaultText) { default = opt.defaultText; }
+        // optionalAttrs (opt ? relatedPackages && opt.relatedPackages != null) { inherit (opt) relatedPackages; };
 
         subOptions =
           let ss = opt.type.getSubOptions opt.loc;