From c9f0b35571c2477395e5330bebd46de0ec08dbdf Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Fri, 19 Feb 2021 01:25:29 +0100 Subject: modules/user/sternenseemann/mandoc: add support for non english manuals Apparently (probably since GNU came along) there are manuals for different languages than english in share/man/$language. This adds support for this in my mandoc module by allowing the user to freely specify the manpath entries under $out. > nmap(1) - Netzwerk-Analysewerkzeug und Sicherheits-/Portscanner --- .../user/sternenseemann/documentation/mandoc.nix | 26 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/user/sternenseemann/documentation/mandoc.nix b/modules/user/sternenseemann/documentation/mandoc.nix index 10fde4eb..594a653b 100644 --- a/modules/user/sternenseemann/documentation/mandoc.nix +++ b/modules/user/sternenseemann/documentation/mandoc.nix @@ -66,6 +66,20 @@ in { ''; }; + manPath = lib.mkOption { + type = with lib.types; listOf str; + default = [ "share/man" ]; + example = lib.literalExample "[ \"share/man\" \"share/man/fr\" ]"; + description = '' + Change the manpath, i. e. the directories where man looks + for section-specific directories of man pages. + You only need to change this setting if you want non-english + man pages or a combination of different languages. All values + must be strings that are a valid path from the target prefix + (without including it). The first value given takes priority. + ''; + }; + generateCaches = lib.mkOption { type = lib.types.bool; default = false; @@ -81,6 +95,7 @@ in { }; config = lib.mkIf cfg.enable { + assertions = [ { assertion = !(cfg.enable && docCfg.man.enable); @@ -99,13 +114,16 @@ in { ++ lib.optional docCfg.dev.enable "devman"; # tell mandoc about man pages systemPackages = [ mandoc ]; - etc."man.conf".text = '' - manpath /run/current-system/sw/share/man - ''; + etc."man.conf".text = lib.concatMapStrings + (path: "manpath /run/current-system/sw/${path}\n") + cfg.manPath; # create mandoc.db for whatis(1), apropos(1) and man(1) -k # TODO(sterni): remove -p for production™ extraSetup = lib.optionalString cfg.generateCaches '' - ${bins.makewhatis} -p -T utf8 $out/share/man + ${bins.makewhatis} -p -T utf8 \ + ${lib.concatMapStringsSep " " + (path: "\"$out/${path}\"") + cfg.manPath} ''; }; }; -- cgit 1.4.1