fork/home-manager
git clone https://git.julia.blue/fork/home-manager
4542db60
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let cfg = config . programs . man ; 6in { 7options = { 8programs . man = { 9enable = mkOption { 10type = types . bool ; 11default = true ; 12description = '' 13Whether to enable manual pages and the {command}`man` 14command. This also includes "man" outputs of all 15`home.packages`. 16'' ; 17}; 18 19package = mkOption { 20type = types . package ; 21default = pkgs . man ; 22defaultText = literalExpression "pkgs.man" ; 23description = "The man package to use." ; 24}; 25 26generateCaches = mkOption { 27type = types . bool ; 28default = false ; 29description = '' 30Whether to generate the manual page index caches using 31{manpage}`mandb(8)`. This allows searching for a page or 32keyword using utilities like {manpage}`apropos(1)`. 33 34This feature is disabled by default because it slows down 35building. If you don't mind waiting a few more seconds when 36Home Manager builds a new generation, you may safely enable 37this option. 38'' ; 39}; 40}; 41}; 42 43config = mkIf cfg . enable { 44home . packages = [ cfg . package ]; 45home . extraOutputsToInstall = [ "man" ]; 46 47# This is mostly copy/pasted/adapted from NixOS' documentation.nix. 48home . file = mkIf cfg . generateCaches { 49".manpath" . text = let 50# Generate a directory containing installed packages' manpages. 51manualPages = pkgs . buildEnv { 52name = "man-paths" ; 53paths = config . home . packages ; 54pathsToLink = [ "/share/man" ]; 55extraOutputsToInstall = [ "man" ]; 56ignoreCollisions = true ; 57}; 58 59# Generate a database of all manpages in ${manualPages}. 60manualCache = pkgs . runCommandLocal "man-cache" { 61nativeBuildInputs = [ cfg . package ]; 62} '' 63# Generate a temporary man.conf so mandb knows where to 64# write cache files. 65echo "MANDB_MAP ${ manualPages } /share/man $ out " > man.conf 66 67# Run mandb to generate cache files: 68mandb -C man.conf --no-straycats --create \ 69${ manualPages } /share/man 70'' ; 71in '' 72MANDB_MAP ${ config . home . profileDirectory } /share/man ${ manualCache } 73'' ; 74}; 75}; 76}