From 1301bdb185c4d0d7c30d0400d76eae8669b5b64d Mon Sep 17 00:00:00 2001 From: pennae Date: Sat, 18 Dec 2021 19:21:21 +0100 Subject: [PATCH] nixos/make-options-doc: turn relatedPackages into links link to search.nixos.org instead of pulling package metadata out of pkgs. this lets us cache docs of a few more modules and provides easier access to package info from the HTML manual, but makes the manpage slightly less useful since package description are no longer rendered. --- nixos/lib/make-options-doc/default.nix | 31 +++++++++++-------- nixos/modules/config/qt5.nix | 3 -- nixos/modules/programs/dmrconfig.nix | 2 -- nixos/modules/programs/tmux.nix | 3 -- nixos/modules/services/hardware/thinkfan.nix | 3 -- nixos/modules/services/networking/searx.nix | 2 -- nixos/modules/services/web-apps/nextcloud.nix | 2 -- nixos/modules/virtualisation/xen-dom0.nix | 4 --- 8 files changed, 18 insertions(+), 32 deletions(-) diff --git a/nixos/lib/make-options-doc/default.nix b/nixos/lib/make-options-doc/default.nix index 4b40af34b18..cc4ddd55d02 100644 --- a/nixos/lib/make-options-doc/default.nix +++ b/nixos/lib/make-options-doc/default.nix @@ -55,10 +55,15 @@ let # ../../../lib/options.nix influences. # # Each element of `relatedPackages` can be either - # - a string: that will be interpreted as an attribute name from `pkgs`, - # - a list: that will be interpreted as an attribute path from `pkgs`, - # - an attrset: that can specify `name`, `path`, `package`, `comment` + # - a string: that will be interpreted as an attribute name from `pkgs` and turned into a link + # to search.nixos.org, + # - a list: that will be interpreted as an attribute path from `pkgs` and turned into a link + # to search.nixos.org, + # - an attrset: that can specify `name`, `path`, `comment` # (either of `name`, `path` is required, the rest are optional). + # + # NOTE: No checks against `pkgs` are made to ensure that the referenced package actually exists. + # Such checks are not compatible with option docs caching. genRelatedPackages = packages: optName: let unpack = p: if lib.isString p then { name = p; } @@ -68,16 +73,16 @@ let let title = args.title or null; name = args.name or (lib.concatStringsSep "." args.path); - path = args.path or [ args.name ]; - package = args.package or (lib.attrByPath path (throw "Invalid package attribute path `${toString path}' found while evaluating `relatedPackages' of option `${optName}'") pkgs); - in "" - + "${lib.optionalString (title != null) "${title} aka "}pkgs.${name} (${package.meta.name})" - + lib.optionalString (!package.meta.available) " [UNAVAILABLE]" - + ": ${package.meta.description or "???"}." - + lib.optionalString (args ? comment) "\n${args.comment}" - # Lots of `longDescription's break DocBook, so we just wrap them into - + lib.optionalString (package.meta ? longDescription) "\n${package.meta.longDescription}" - + ""; + in '' + + + + ${lib.optionalString (title != null) "${title} aka "}pkgs.${name} + + + ${lib.optionalString (args ? comment) "${args.comment}"} + + ''; in "${lib.concatStringsSep "\n" (map (p: describe (unpack p)) packages)}"; # Remove invisible and internal options. diff --git a/nixos/modules/config/qt5.nix b/nixos/modules/config/qt5.nix index 24b2a6f9f4a..eabba9ad95f 100644 --- a/nixos/modules/config/qt5.nix +++ b/nixos/modules/config/qt5.nix @@ -101,7 +101,4 @@ in environment.systemPackages = packages; }; - - # uses relatedPackages - meta.buildDocsInSandbox = false; } diff --git a/nixos/modules/programs/dmrconfig.nix b/nixos/modules/programs/dmrconfig.nix index 73e1b529da9..d2a5117c48e 100644 --- a/nixos/modules/programs/dmrconfig.nix +++ b/nixos/modules/programs/dmrconfig.nix @@ -7,8 +7,6 @@ let in { meta.maintainers = [ maintainers.etu ]; - # uses relatedPackages - meta.buildDocsInSandbox = false; ###### interface options = { diff --git a/nixos/modules/programs/tmux.nix b/nixos/modules/programs/tmux.nix index 54c32a463e5..c39908751d2 100644 --- a/nixos/modules/programs/tmux.nix +++ b/nixos/modules/programs/tmux.nix @@ -185,7 +185,4 @@ in { imports = [ (lib.mkRenamedOptionModule [ "programs" "tmux" "extraTmuxConf" ] [ "programs" "tmux" "extraConfig" ]) ]; - - # uses relatedPackages - meta.buildDocsInSandbox = false; } diff --git a/nixos/modules/services/hardware/thinkfan.nix b/nixos/modules/services/hardware/thinkfan.nix index 1c5b428d5d6..4ea829e496e 100644 --- a/nixos/modules/services/hardware/thinkfan.nix +++ b/nixos/modules/services/hardware/thinkfan.nix @@ -221,7 +221,4 @@ in { boot.extraModprobeConfig = "options thinkpad_acpi experimental=1 fan_control=1"; }; - - # uses relatedPackages - meta.buildDocsInSandbox = false; } diff --git a/nixos/modules/services/networking/searx.nix b/nixos/modules/services/networking/searx.nix index 6fd81521e7f..b73f255eb9d 100644 --- a/nixos/modules/services/networking/searx.nix +++ b/nixos/modules/services/networking/searx.nix @@ -228,6 +228,4 @@ in }; meta.maintainers = with maintainers; [ rnhmjoj ]; - # uses relatedPackages - meta.buildDocsInSandbox = false; } diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index e04b30a7d62..6692d67081c 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -932,6 +932,4 @@ in { ]); meta.doc = ./nextcloud.xml; - # uses relatedPackages - meta.buildDocsInSandbox = false; } diff --git a/nixos/modules/virtualisation/xen-dom0.nix b/nixos/modules/virtualisation/xen-dom0.nix index fc640bd947b..975eed10cd2 100644 --- a/nixos/modules/virtualisation/xen-dom0.nix +++ b/nixos/modules/virtualisation/xen-dom0.nix @@ -450,8 +450,4 @@ in }; }; - - - # uses relatedPackages - meta.buildDocsInSandbox = false; }