mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-11 04:02:55 +03:00
nixos/documentation: add option to generate caches
Previously the NixOS-specific configuration for man-db was in the package itself and /etc/man.conf was completely ignored. This change moves it to /etc/man_db.conf, making declarative configuration practical again. It's now possible to generate the mandb caches for all packages installed through NixOS `environment.systemPackages` at build-time. The standard location for the stateful cache (/var/cache/man) is also configured to allow users to run `mandb` manually if they wish. Since generating the cache can be expensive the option is off by default.
This commit is contained in:
parent
dfff485819
commit
edc6a76cc0
@ -102,6 +102,16 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
man.generateCaches = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to generate the manual page index caches using
|
||||
<literal>mandb(8)</literal>. This allows searching for a page or
|
||||
keyword using utilities like <literal>apropos(1)</literal>.
|
||||
'';
|
||||
};
|
||||
|
||||
info.enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
@ -187,7 +197,33 @@ in
|
||||
environment.systemPackages = [ pkgs.man-db ];
|
||||
environment.pathsToLink = [ "/share/man" ];
|
||||
environment.extraOutputsToInstall = [ "man" ] ++ optional cfg.dev.enable "devman";
|
||||
environment.etc."man.conf".source = "${pkgs.man-db}/etc/man_db.conf";
|
||||
environment.etc."man_db.conf".text =
|
||||
let
|
||||
manualPages = pkgs.buildEnv {
|
||||
name = "man-paths";
|
||||
paths = config.environment.systemPackages;
|
||||
pathsToLink = [ "/share/man" ];
|
||||
extraOutputsToInstall = ["man"];
|
||||
ignoreCollisions = true;
|
||||
};
|
||||
manualCache = pkgs.runCommandLocal "man-cache" { }
|
||||
''
|
||||
echo "MANDB_MAP ${manualPages}/share/man $out" > man.conf
|
||||
${pkgs.man-db}/bin/mandb -C man.conf -psc
|
||||
'';
|
||||
in
|
||||
''
|
||||
# Manual pages paths for NixOS
|
||||
MANPATH_MAP /run/current-system/sw/bin /run/current-system/sw/share/man
|
||||
MANPATH_MAP /run/wrappers/bin /run/current-system/sw/share/man
|
||||
|
||||
${optionalString cfg.man.generateCaches ''
|
||||
# Generated manual pages cache for NixOS (immutable)
|
||||
MANDB_MAP /run/current-system/sw/share/man ${manualCache}
|
||||
''}
|
||||
# Manual pages caches for NixOS
|
||||
MANDB_MAP /run/current-system/sw/share/man /var/cache/man/nixos
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.info.enable {
|
||||
|
Loading…
Reference in New Issue
Block a user