1 { config, lib, pkgs, ... }:
4 makewhatis = "${lib.getBin cfg.package}/bin/makewhatis";
6 cfg = config.documentation.man.mandoc;
9 meta.maintainers = [ lib.maintainers.sternenseemann ];
12 documentation.man.mandoc = {
13 enable = lib.mkEnableOption (lib.mdDoc "mandoc as the default man page viewer");
15 manPath = lib.mkOption {
16 type = with lib.types; listOf str;
17 default = [ "share/man" ];
18 example = lib.literalExpression "[ \"share/man\" \"share/man/fr\" ]";
19 description = lib.mdDoc ''
20 Change the manpath, i. e. the directories where
22 looks for section-specific directories of man pages.
23 You only need to change this setting if you want extra man pages
24 (e. g. in non-english languages). All values must be strings that
25 are a valid path from the target prefix (without including it).
26 The first value given takes priority.
30 package = lib.mkOption {
31 type = lib.types.package;
32 default = pkgs.mandoc;
33 defaultText = lib.literalExpression "pkgs.mandoc";
34 description = lib.mdDoc ''
35 The `mandoc` derivation to use. Useful to override
36 configuration options used for the package.
42 config = lib.mkIf cfg.enable {
44 systemPackages = [ cfg.package ];
46 # tell mandoc about man pages
47 etc."man.conf".text = lib.concatMapStrings (path: ''
48 manpath /run/current-system/sw/${path}
51 # create mandoc.db for whatis(1), apropos(1) and man(1) -k
52 # TODO(@sternenseemman): fix symlinked directories not getting indexed,
53 # see: https://inbox.vuxu.org/mandoc-tech/20210906171231.GF83680@athene.usta.de/T/#e85f773c1781e3fef85562b2794f9cad7b2909a3c
54 extraSetup = lib.mkIf config.documentation.man.generateCaches ''
55 ${makewhatis} -T utf8 ${
56 lib.concatMapStringsSep " " (path:
57 "$out/" + lib.escapeShellArg path