about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-02-19 01:25:29 +0100
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-02-19 01:28:58 +0100
commitc9f0b35571c2477395e5330bebd46de0ec08dbdf (patch)
tree290775ec6109241c7d00a6d877cf8122086e0179 /modules
parentd23353c4dbf06cd074e243a30412604a9c69e581 (diff)
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
Diffstat (limited to 'modules')
-rw-r--r--modules/user/sternenseemann/documentation/mandoc.nix26
1 files changed, 22 insertions, 4 deletions
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}
       '';
     };
   };