at 23.05-pre 2.1 kB view raw
1{ config, lib, pkgs, ... }: 2 3let 4 makewhatis = "${lib.getBin cfg.package}/bin/makewhatis"; 5 6 cfg = config.documentation.man.mandoc; 7 8in { 9 meta.maintainers = [ lib.maintainers.sternenseemann ]; 10 11 options = { 12 documentation.man.mandoc = { 13 enable = lib.mkEnableOption (lib.mdDoc "mandoc as the default man page viewer"); 14 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 21 {manpage}`man(1)` 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. 27 ''; 28 }; 29 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. 37 ''; 38 }; 39 }; 40 }; 41 42 config = lib.mkIf cfg.enable { 43 environment = { 44 systemPackages = [ cfg.package ]; 45 46 # tell mandoc about man pages 47 etc."man.conf".text = lib.concatMapStrings (path: '' 48 manpath /run/current-system/sw/${path} 49 '') cfg.manPath; 50 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 58 ) cfg.manPath 59 } 60 ''; 61 }; 62 }; 63}