1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-17 19:21:04 +00:00

doc: extract optionsDoc into its own package

This commit is contained in:
Philip Taron 2024-07-26 11:07:58 -07:00
parent ee6a243ea4
commit eac67316dc
No known key found for this signature in database
2 changed files with 30 additions and 22 deletions

View file

@ -1,7 +1,6 @@
{ pkgs ? (import ./.. { }), nixpkgs ? { }}:
let
inherit (pkgs) lib callPackage;
inherit (lib) hasPrefix removePrefix;
fs = lib.fileset;
common = import ./common.nix;
@ -12,27 +11,9 @@ let
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 = 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;
};
};
# 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 { };
in pkgs.stdenv.mkDerivation {
name = "nixpkgs-manual";

View file

@ -0,0 +1,27 @@
{ lib, nixosOptionsDoc }:
let
modules = lib.evalModules {
modules = [ ../../pkgs/top-level/config.nix ];
class = "nixpkgsConfig";
};
root = toString ../..;
transformDeclaration =
decl:
let
declStr = toString decl;
subpath = lib.removePrefix "/" (lib.removePrefix root declStr);
in
assert lib.hasPrefix root declStr;
{
url = "https://github.com/NixOS/nixpkgs/blob/master/${subpath}";
name = subpath;
};
in
nixosOptionsDoc {
inherit (modules) options;
documentType = "none";
transformOptions = opt: opt // { declarations = map transformDeclaration opt.declarations; };
}