From 459957f9d4d2e82424c7819eb36de4ec7644ef8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Mon, 6 Sep 2021 18:27:52 +0200 Subject: [PATCH] nixos/documentation: expose manualPages Allows advanced users to select what packages they want to generate the man cache for, and even more advanced users to make manualPages content-addressed to avoid needless rebuilds. --- nixos/modules/misc/documentation.nix | 30 ++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/nixos/modules/misc/documentation.nix b/nixos/modules/misc/documentation.nix index 7e04f0f16a99..f22ea5f9aeb8 100644 --- a/nixos/modules/misc/documentation.nix +++ b/nixos/modules/misc/documentation.nix @@ -120,6 +120,24 @@ in ''; }; + man.manualPages = mkOption { + type = types.path; + default = pkgs.buildEnv { + name = "man-paths"; + paths = config.environment.systemPackages; + pathsToLink = [ "/share/man" ]; + extraOutputsToInstall = ["man"]; + ignoreCollisions = true; + }; + defaultText = "all man pages in config.environment.systemPackages"; + description = '' + The manual pages to generate caches for if + is enabled. Must be a path to a directory with man pages under + /share/man; see the source for an example. + Advanced users can make this a content-addressed derivation to save a few rebuilds. + ''; + }; + info.enable = mkOption { type = types.bool; default = true; @@ -207,16 +225,8 @@ in environment.extraOutputsToInstall = [ "man" ] ++ optional cfg.dev.enable "devman"; environment.etc."man_db.conf".text = let - manualPages = pkgs.buildEnv { - name = "man-paths"; - paths = config.environment.systemPackages; - pathsToLink = [ "/share/man" ]; - extraOutputsToInstall = ["man"]; - ignoreCollisions = true; - }; - manualCache = pkgs.runCommandLocal "man-cache" { } - '' - echo "MANDB_MAP ${manualPages}/share/man $out" > man.conf + manualCache = pkgs.runCommandLocal "man-cache" { } '' + echo "MANDB_MAP ${cfg.man.manualPages}/share/man $out" > man.conf ${pkgs.man-db}/bin/mandb -C man.conf -psc >/dev/null 2>&1 ''; in