2022-01-03 16:56:52 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.documentation.man.man-db;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
documentation.man.man-db = {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = lib.mkEnableOption "man-db as the default man page viewer" // {
|
2022-01-03 16:56:52 +00:00
|
|
|
default = config.documentation.man.enable;
|
|
|
|
defaultText = lib.literalExpression "config.documentation.man.enable";
|
|
|
|
example = false;
|
|
|
|
};
|
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
skipPackages = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.package;
|
|
|
|
default = [];
|
|
|
|
internal = true;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2023-01-20 10:41:00 +00:00
|
|
|
Packages to *not* include in the man-db.
|
|
|
|
This can be useful to avoid unnecessary rebuilds due to packages that change frequently, like nixos-version.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
manualPages = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
|
|
|
default = pkgs.buildEnv {
|
|
|
|
name = "man-paths";
|
2023-01-20 10:41:00 +00:00
|
|
|
paths = lib.subtractLists cfg.skipPackages config.environment.systemPackages;
|
2022-01-03 16:56:52 +00:00
|
|
|
pathsToLink = [ "/share/man" ];
|
|
|
|
extraOutputsToInstall = [ "man" ]
|
|
|
|
++ lib.optionals config.documentation.dev.enable [ "devman" ];
|
|
|
|
ignoreCollisions = true;
|
|
|
|
};
|
2022-06-26 10:26:21 +00:00
|
|
|
defaultText = lib.literalMD "all man pages in {option}`config.environment.systemPackages`";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-06-26 10:26:21 +00:00
|
|
|
The manual pages to generate caches for if {option}`documentation.man.generateCaches`
|
2022-01-03 16:56:52 +00:00
|
|
|
is enabled. Must be a path to a directory with man pages under
|
2022-06-26 10:26:21 +00:00
|
|
|
`/share/man`; see the source for an example.
|
2022-01-03 16:56:52 +00:00
|
|
|
Advanced users can make this a content-addressed derivation to save a few rebuilds.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
default = pkgs.man-db;
|
|
|
|
defaultText = lib.literalExpression "pkgs.man-db";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-08-12 12:06:08 +00:00
|
|
|
The `man-db` derivation to use. Useful to override
|
2022-01-03 16:56:52 +00:00
|
|
|
configuration options used for the package.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
imports = [
|
|
|
|
(lib.mkRenamedOptionModule [ "documentation" "man" "manualPages" ] [ "documentation" "man" "man-db" "manualPages" ])
|
|
|
|
];
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
environment.etc."man_db.conf".text =
|
|
|
|
let
|
2022-12-28 21:21:41 +00:00
|
|
|
manualCache = pkgs.runCommand "man-cache" {
|
|
|
|
nativeBuildInputs = [ cfg.package ];
|
|
|
|
} ''
|
2022-01-03 16:56:52 +00:00
|
|
|
echo "MANDB_MAP ${cfg.manualPages}/share/man $out" > man.conf
|
2022-12-28 21:21:41 +00:00
|
|
|
mandb -C man.conf -psc >/dev/null 2>&1
|
2022-01-03 16:56:52 +00: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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|