summary refs log tree commit diff
path: root/doc/default.nix
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2023-06-23 01:03:02 +0200
committerpennae <github@quasiparticle.net>2023-07-01 20:59:30 +0200
commit70cbd8c6c07378c7bf8b6d224d904c33a430914f (patch)
treee1618477810d8bf6300a59202b16c024504e2947 /doc/default.nix
parentf397309f4e6c7a219a7703b629f6a4e8d4e7a58b (diff)
downloadnixpkgs-70cbd8c6c07378c7bf8b6d224d904c33a430914f.tar
nixpkgs-70cbd8c6c07378c7bf8b6d224d904c33a430914f.tar.gz
nixpkgs-70cbd8c6c07378c7bf8b6d224d904c33a430914f.tar.bz2
nixpkgs-70cbd8c6c07378c7bf8b6d224d904c33a430914f.tar.lz
nixpkgs-70cbd8c6c07378c7bf8b6d224d904c33a430914f.tar.xz
nixpkgs-70cbd8c6c07378c7bf8b6d224d904c33a430914f.tar.zst
nixpkgs-70cbd8c6c07378c7bf8b6d224d904c33a430914f.zip
doc: pull option docs out of doc-support
this leaves doc-support as a simple wrapper around function docs. this
wrapper will go away very soon as well.
Diffstat (limited to 'doc/default.nix')
-rw-r--r--doc/default.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/default.nix b/doc/default.nix
index b8b25c3b4e0..2133a06e0f4 100644
--- a/doc/default.nix
+++ b/doc/default.nix
@@ -1,5 +1,8 @@
 { pkgs ? (import ./.. { }), nixpkgs ? { }}:
 let
+  inherit (pkgs) lib;
+  inherit (lib) hasPrefix removePrefix;
+
   doc-support = import ./doc-support { inherit pkgs nixpkgs; };
 
   epub = pkgs.runCommand "manual.epub" {
@@ -43,6 +46,28 @@ let
     zip -0Xq "$out" mimetype
     cd scratch && zip -Xr9D "$out" *
   '';
+
+  # NB: This file describes the Nixpkgs manual, which happens to use module
+  #     docs infra originally developed for NixOS.
+  optionsDoc = pkgs.nixosOptionsDoc {
+    inherit (pkgs.lib.evalModules {
+      modules = [ ../pkgs/top-level/config.nix ];
+      class = "nixpkgsConfig";
+    }) options;
+    documentType = "none";
+    transformOptions = opt:
+      opt // {
+        declarations =
+          map
+            (decl:
+              if hasPrefix (toString ../..) (toString decl)
+              then
+                let subpath = removePrefix "/" (removePrefix (toString ../.) (toString decl));
+                in { url = "https://github.com/NixOS/nixpkgs/blob/master/${subpath}"; name = subpath; }
+              else decl)
+            opt.declarations;
+        };
+  };
 in pkgs.stdenv.mkDerivation {
   name = "nixpkgs-manual";
 
@@ -54,6 +79,7 @@ in pkgs.stdenv.mkDerivation {
 
   postPatch = ''
     ln -s ${doc-support} ./doc-support/result
+    ln -s ${optionsDoc.optionsJSON}/share/doc/nixos/options.json ./config-options.json
   '';
 
   buildPhase = ''