2021-09-24 19:20:23 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.documentation.man.man-db;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
documentation.man.man-db = {
|
2022-08-28 21:18:44 +02:00
|
|
|
enable = lib.mkEnableOption (lib.mdDoc "man-db as the default man page viewer") // {
|
2021-09-24 19:20:23 +02:00
|
|
|
default = config.documentation.man.enable;
|
|
|
|
defaultText = lib.literalExpression "config.documentation.man.enable";
|
|
|
|
example = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
manualPages = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
|
|
|
default = pkgs.buildEnv {
|
|
|
|
name = "man-paths";
|
|
|
|
paths = config.environment.systemPackages;
|
|
|
|
pathsToLink = [ "/share/man" ];
|
|
|
|
extraOutputsToInstall = [ "man" ]
|
|
|
|
++ lib.optionals config.documentation.dev.enable [ "devman" ];
|
|
|
|
ignoreCollisions = true;
|
|
|
|
};
|
2022-06-03 21:47:57 +02:00
|
|
|
defaultText = lib.literalMD "all man pages in {option}`config.environment.systemPackages`";
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
The manual pages to generate caches for if {option}`documentation.man.generateCaches`
|
2021-09-24 19:20:23 +02:00
|
|
|
is enabled. Must be a path to a directory with man pages under
|
2022-06-03 21:47:57 +02:00
|
|
|
`/share/man`; see the source for an example.
|
2021-09-24 19:20:23 +02:00
|
|
|
Advanced users can make this a content-addressed derivation to save a few rebuilds.
|
|
|
|
'';
|
|
|
|
};
|
2021-10-02 15:26:54 +02:00
|
|
|
|
|
|
|
package = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
default = pkgs.man-db;
|
|
|
|
defaultText = lib.literalExpression "pkgs.man-db";
|
2022-07-20 12:32:04 +02:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
The `man-db` derivation to use. Useful to override
|
2021-10-02 15:26:54 +02:00
|
|
|
configuration options used for the package.
|
|
|
|
'';
|
|
|
|
};
|
2021-09-24 19:20:23 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
imports = [
|
|
|
|
(lib.mkRenamedOptionModule [ "documentation" "man" "manualPages" ] [ "documentation" "man" "man-db" "manualPages" ])
|
|
|
|
];
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2021-10-02 15:26:54 +02:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
2021-09-24 19:20:23 +02:00
|
|
|
environment.etc."man_db.conf".text =
|
|
|
|
let
|
|
|
|
manualCache = pkgs.runCommandLocal "man-cache" { } ''
|
|
|
|
echo "MANDB_MAP ${cfg.manualPages}/share/man $out" > man.conf
|
2021-10-02 15:26:54 +02:00
|
|
|
${cfg.package}/bin/mandb -C man.conf -psc >/dev/null 2>&1
|
2021-09-24 19:20:23 +02:00
|
|
|
'';
|
|
|
|
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
|
|
|
|
|
|
|
|
${lib.optionalString config.documentation.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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|