about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/default.nix102
-rw-r--r--doc/doc-support/epub.nix1
-rw-r--r--doc/doc-support/lib-function-docs.nix2
-rw-r--r--doc/doc-support/options-doc.nix1
-rw-r--r--doc/doc-support/package.nix103
-rw-r--r--doc/tests/manpage-urls.nix1
6 files changed, 112 insertions, 98 deletions
diff --git a/doc/default.nix b/doc/default.nix
index 10c338e73b9f..669179141060 100644
--- a/doc/default.nix
+++ b/doc/default.nix
@@ -1,98 +1,6 @@
-{ pkgs ? (import ./.. { }), nixpkgs ? { }}:
-let
-  inherit (pkgs) lib callPackage;
-  fs = lib.fileset;
+{
+  pkgs ? (import ./.. { }),
+  nixpkgs ? { },
+}:
 
-  common = import ./common.nix;
-
-  lib-docs = callPackage ./doc-support/lib-function-docs.nix {
-    inherit nixpkgs;
-  };
-
-  epub = callPackage ./doc-support/epub.nix { };
-
-  # NB: This file describes the Nixpkgs manual, which happens to use module docs infra originally developed for NixOS.
-  optionsDoc = callPackage ./doc-support/options-doc.nix { };
-
-  pythonInterpreterTable = pkgs.callPackage ./doc-support/python-interpreter-table.nix {};
-
-in pkgs.stdenv.mkDerivation {
-  name = "nixpkgs-manual";
-
-  nativeBuildInputs = with pkgs; [
-    nixos-render-docs
-  ];
-
-  src = fs.toSource {
-    root = ./.;
-    fileset = fs.unions [
-      (fs.fileFilter (file:
-        file.hasExt "md"
-        || file.hasExt "md.in"
-      ) ./.)
-      ./style.css
-      ./anchor-use.js
-      ./anchor.min.js
-      ./manpage-urls.json
-    ];
-  };
-
-  postPatch = ''
-    ln -s ${optionsDoc.optionsJSON}/share/doc/nixos/options.json ./config-options.json
-  '';
-
-  buildPhase = ''
-    substituteInPlace ./languages-frameworks/python.section.md \
-      --subst-var-by python-interpreter-table "$(<"${pythonInterpreterTable}")"
-
-    cat \
-      ./functions/library.md.in \
-      ${lib-docs}/index.md \
-      > ./functions/library.md
-    substitute ./manual.md.in ./manual.md \
-      --replace-fail '@MANUAL_VERSION@' '${pkgs.lib.version}'
-
-    mkdir -p out/media
-
-    mkdir -p out/highlightjs
-    cp -t out/highlightjs \
-      ${pkgs.documentation-highlighter}/highlight.pack.js \
-      ${pkgs.documentation-highlighter}/LICENSE \
-      ${pkgs.documentation-highlighter}/mono-blue.css \
-      ${pkgs.documentation-highlighter}/loader.js
-
-    cp -t out ./style.css ./anchor.min.js ./anchor-use.js
-
-    nixos-render-docs manual html \
-      --manpage-urls ./manpage-urls.json \
-      --revision ${pkgs.lib.trivial.revisionWithDefault (pkgs.rev or "master")} \
-      --stylesheet style.css \
-      --stylesheet highlightjs/mono-blue.css \
-      --script ./highlightjs/highlight.pack.js \
-      --script ./highlightjs/loader.js \
-      --script ./anchor.min.js \
-      --script ./anchor-use.js \
-      --toc-depth 1 \
-      --section-toc-depth 1 \
-      manual.md \
-      out/index.html
-  '';
-
-  installPhase = ''
-    dest="$out/${common.outputPath}"
-    mkdir -p "$(dirname "$dest")"
-    mv out "$dest"
-    mv "$dest/index.html" "$dest/${common.indexPath}"
-
-    cp ${epub} "$dest/nixpkgs-manual.epub"
-
-    mkdir -p $out/nix-support/
-    echo "doc manual $dest ${common.indexPath}" >> $out/nix-support/hydra-build-products
-    echo "doc manual $dest nixpkgs-manual.epub" >> $out/nix-support/hydra-build-products
-  '';
-
-  passthru = {
-    inherit pythonInterpreterTable;
-    tests.manpage-urls = callPackage ./tests/manpage-urls.nix { };
-  };
-}
+pkgs.callPackage ./doc-support/package.nix { inherit nixpkgs; }
diff --git a/doc/doc-support/epub.nix b/doc/doc-support/epub.nix
index b916d3579880..259207535a09 100644
--- a/doc/doc-support/epub.nix
+++ b/doc/doc-support/epub.nix
@@ -1,3 +1,4 @@
+# To run this derivation, `nix-build -A nixpkgs-manual.epub`
 {
   lib,
   runCommand,
diff --git a/doc/doc-support/lib-function-docs.nix b/doc/doc-support/lib-function-docs.nix
index b1c197ae1627..1ce052e4852f 100644
--- a/doc/doc-support/lib-function-docs.nix
+++ b/doc/doc-support/lib-function-docs.nix
@@ -1,5 +1,5 @@
 # Generates the documentation for library functions via nixdoc.
-
+# To run this derivation, `nix-build -A nixpkgs-manual.lib-docs`
 {
   lib,
   stdenvNoCC,
diff --git a/doc/doc-support/options-doc.nix b/doc/doc-support/options-doc.nix
index 6405ef9efe6f..e1684d35700e 100644
--- a/doc/doc-support/options-doc.nix
+++ b/doc/doc-support/options-doc.nix
@@ -1,3 +1,4 @@
+# To run this derivation, `nix-build -A nixpkgs-manual.optionsDoc`
 { lib, nixosOptionsDoc }:
 
 let
diff --git a/doc/doc-support/package.nix b/doc/doc-support/package.nix
new file mode 100644
index 000000000000..aa70184bf935
--- /dev/null
+++ b/doc/doc-support/package.nix
@@ -0,0 +1,103 @@
+{
+  lib,
+  stdenvNoCC,
+  callPackage,
+  documentation-highlighter,
+  nixos-render-docs,
+  nixpkgs ? { },
+}:
+
+let
+  common = import ../common.nix;
+in
+
+stdenvNoCC.mkDerivation (
+  finalAttrs:
+  let
+    inherit (finalAttrs.finalPackage.optionsDoc) optionsJSON;
+    inherit (finalAttrs.finalPackage) epub lib-docs pythonInterpreterTable;
+  in
+  {
+    name = "nixpkgs-manual";
+
+    nativeBuildInputs = [ nixos-render-docs ];
+
+    src = lib.fileset.toSource {
+      root = ../.;
+      fileset = lib.fileset.unions [
+        (lib.fileset.fileFilter (file: file.hasExt "md" || file.hasExt "md.in") ../.)
+        ../style.css
+        ../anchor-use.js
+        ../anchor.min.js
+        ../manpage-urls.json
+      ];
+    };
+
+    postPatch = ''
+      ln -s ${optionsJSON}/share/doc/nixos/options.json ./config-options.json
+    '';
+
+    buildPhase = ''
+      substituteInPlace ./languages-frameworks/python.section.md \
+        --subst-var-by python-interpreter-table "$(<"${pythonInterpreterTable}")"
+
+      cat \
+        ./functions/library.md.in \
+        ${lib-docs}/index.md \
+        > ./functions/library.md
+      substitute ./manual.md.in ./manual.md \
+        --replace-fail '@MANUAL_VERSION@' '${lib.version}'
+
+      mkdir -p out/media
+
+      mkdir -p out/highlightjs
+      cp -t out/highlightjs \
+        ${documentation-highlighter}/highlight.pack.js \
+        ${documentation-highlighter}/LICENSE \
+        ${documentation-highlighter}/mono-blue.css \
+        ${documentation-highlighter}/loader.js
+
+      cp -t out ./style.css ./anchor.min.js ./anchor-use.js
+
+      nixos-render-docs manual html \
+        --manpage-urls ./manpage-urls.json \
+        --revision ${lib.trivial.revisionWithDefault (nixpkgs.rev or "master")} \
+        --stylesheet style.css \
+        --stylesheet highlightjs/mono-blue.css \
+        --script ./highlightjs/highlight.pack.js \
+        --script ./highlightjs/loader.js \
+        --script ./anchor.min.js \
+        --script ./anchor-use.js \
+        --toc-depth 1 \
+        --section-toc-depth 1 \
+        manual.md \
+        out/index.html
+    '';
+
+    installPhase = ''
+      dest="$out/${common.outputPath}"
+      mkdir -p "$(dirname "$dest")"
+      mv out "$dest"
+      mv "$dest/index.html" "$dest/${common.indexPath}"
+
+      cp ${epub} "$dest/nixpkgs-manual.epub"
+
+      mkdir -p $out/nix-support/
+      echo "doc manual $dest ${common.indexPath}" >> $out/nix-support/hydra-build-products
+      echo "doc manual $dest nixpkgs-manual.epub" >> $out/nix-support/hydra-build-products
+    '';
+
+    passthru = {
+      lib-docs = callPackage ./lib-function-docs.nix { inherit nixpkgs; };
+
+      epub = callPackage ./epub.nix { };
+
+      # NB: This file describes the Nixpkgs manual, which happens to use module docs infra originally developed for NixOS.
+      optionsDoc = callPackage ./options-doc.nix { };
+
+      pythonInterpreterTable = callPackage ./python-interpreter-table.nix { };
+
+      tests.manpage-urls = callPackage ../tests/manpage-urls.nix { };
+    };
+  }
+)
diff --git a/doc/tests/manpage-urls.nix b/doc/tests/manpage-urls.nix
index 084fabdd0f3d..0a3adec20655 100644
--- a/doc/tests/manpage-urls.nix
+++ b/doc/tests/manpage-urls.nix
@@ -1,3 +1,4 @@
+# To run this derivation, `nix-build -A nixpkgs-manual.tests.manpage-urls`
 {
   lib,
   runCommand,