about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authoraleksana <me@aleksana.moe>2023-12-25 14:25:55 +0800
committersternenseemann <sternenseemann@systemli.org>2024-03-20 00:56:18 +0100
commitb60f6b118bb0a7a2b5a91f5712ee41c150dbd0a8 (patch)
tree04e1839872f09cc29fff61abd195305c18ab40eb /nixos
parentda089cf63a1377fe8febcf1bf6d0d323a0077e02 (diff)
downloadnixlib-b60f6b118bb0a7a2b5a91f5712ee41c150dbd0a8.tar
nixlib-b60f6b118bb0a7a2b5a91f5712ee41c150dbd0a8.tar.gz
nixlib-b60f6b118bb0a7a2b5a91f5712ee41c150dbd0a8.tar.bz2
nixlib-b60f6b118bb0a7a2b5a91f5712ee41c150dbd0a8.tar.lz
nixlib-b60f6b118bb0a7a2b5a91f5712ee41c150dbd0a8.tar.xz
nixlib-b60f6b118bb0a7a2b5a91f5712ee41c150dbd0a8.tar.zst
nixlib-b60f6b118bb0a7a2b5a91f5712ee41c150dbd0a8.zip
nixos/mandoc: add leading slash to manPath
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/misc/mandoc.nix8
1 files changed, 6 insertions, 2 deletions
diff --git a/nixos/modules/misc/mandoc.nix b/nixos/modules/misc/mandoc.nix
index 797771829a2a..706e2ac2c283 100644
--- a/nixos/modules/misc/mandoc.nix
+++ b/nixos/modules/misc/mandoc.nix
@@ -17,6 +17,8 @@ let
       )
       output
   );
+
+  makeLeadingSlashes = map (path: if builtins.substring 0 1 path != "/" then "/${path}" else path);
 in
 {
   meta.maintainers = [ lib.maintainers.sternenseemann ];
@@ -29,6 +31,7 @@ in
         type = with lib.types; listOf str;
         default = [ "share/man" ];
         example = lib.literalExpression "[ \"share/man\" \"share/man/fr\" ]";
+        apply = makeLeadingSlashes;
         description = ''
           Change the paths included in the MANPATH environment variable,
           i. e. the directories where {manpage}`man(1)`
@@ -46,6 +49,7 @@ in
         default = cfg.manPath;
         defaultText = lib.literalExpression "config.documentation.man.mandoc.manPath";
         example = lib.literalExpression "[ \"share/man\" \"share/man/fr\" ]";
+        apply = makeLeadingSlashes;
         description = ''
           Change the paths where mandoc {manpage}`makewhatis(8)`generates the
           manual page index caches. {option}`documentation.man.generateCaches`
@@ -199,14 +203,14 @@ in
       # TODO(@sternenseemman): fix symlinked directories not getting indexed,
       # see: https://inbox.vuxu.org/mandoc-tech/20210906171231.GF83680@athene.usta.de/T/#e85f773c1781e3fef85562b2794f9cad7b2909a3c
       extraSetup = lib.mkIf config.documentation.man.generateCaches ''
-        for man_path in ${lib.concatMapStringsSep " " (path: "$out/" + lib.escapeShellArg path) cfg.cachePath}
+        for man_path in ${lib.concatMapStringsSep " " (path: "$out" + lib.escapeShellArg path) cfg.cachePath}
         do
           [[ -d "$man_path" ]] && ${makewhatis} -T utf8 $man_path
         done
       '';
 
       # tell mandoc the paths containing man pages
-      profileRelativeSessionVariables."MANPATH" = map (path: if builtins.substring 0 1 path != "/" then "/${path}" else path) cfg.manPath;
+      profileRelativeSessionVariables."MANPATH" = lib.mkIf (cfg.manPath != [ ]) cfg.manPath;
     };
   };
 }