forked from mirrors/nixpkgs
nixos/mandoc: init
Adds a NixOS module which allows using mandoc as the main manual viewer. It can be used as a drop-in replacement for documentation.man which relies on GNU's man-db and provides more or less the same features. The generateCaches option requires a different implementation for mandoc, so it is hard to share code between the two modules -- hence it has been implemented separately. Using both at the same time makes little sense and wouldn't quite work, so there's an assertion to prevent it. To make makewhatis(8) index manual pages which are symlinks to the nix store, we need to set READ_ALLOWED_PATH to include `builtins.storeDir`. For background and discussion see: https://inbox.vuxu.org/mandoc-tech/c9932669-e9d4-1454-8708-7c8e36967e8e@systemli.org/T/
This commit is contained in:
parent
bcc4c34640
commit
f4f7238860
2 changed files with 63 additions and 1 deletions
nixos/modules/misc
|
@ -207,8 +207,19 @@ in
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = !(cfg.man.man-db.enable && cfg.man.mandoc.enable);
|
||||
message = ''
|
||||
man-db and mandoc can't be used as the default man page viewer at the same time!
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
# The actual implementation for this lives in man-db.nix
|
||||
# The actual implementation for this lives in man-db.nix or mandoc.nix,
|
||||
# depending on which backend is active.
|
||||
(mkIf cfg.man.enable {
|
||||
environment.pathsToLink = [ "/share/man" ];
|
||||
environment.extraOutputsToInstall = [ "man" ] ++ optional cfg.dev.enable "devman";
|
||||
|
|
51
nixos/modules/misc/mandoc.nix
Normal file
51
nixos/modules/misc/mandoc.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
makewhatis = "${lib.getBin pkgs.mandoc}/bin/makewhatis";
|
||||
|
||||
cfg = config.documentation.man.mandoc;
|
||||
|
||||
in {
|
||||
meta.maintainers = [ lib.maintainers.sternenseemann ];
|
||||
|
||||
options = {
|
||||
documentation.man.mandoc = {
|
||||
enable = lib.mkEnableOption "mandoc as the default man page viewer";
|
||||
|
||||
manPath = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
default = [ "share/man" ];
|
||||
example = lib.literalExpression "[ \"share/man\" \"share/man/fr\" ]";
|
||||
description = ''
|
||||
Change the manpath, i. e. the directories where
|
||||
<citerefentry><refentrytitle>man</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
||||
looks for section-specific directories of man pages.
|
||||
You only need to change this setting if you want extra man pages
|
||||
(e. g. in non-english languages). All values must be strings that
|
||||
are a valid path from the target prefix (without including it).
|
||||
The first value given takes priority.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment = {
|
||||
systemPackages = [ pkgs.mandoc ];
|
||||
|
||||
# tell mandoc about man pages
|
||||
etc."man.conf".text = lib.concatMapStrings (path: ''
|
||||
manpath /run/current-system/sw/${path}
|
||||
'') cfg.manPath;
|
||||
|
||||
# create mandoc.db for whatis(1), apropos(1) and man(1) -k
|
||||
# TODO(@sternenseemman): fix symlinked directories not getting indexed,
|
||||
# see: https://inbox.vuxu.org/mandoc-tech/20210906171231.GF83680@athene.usta.de/T/#e85f773c1781e3fef85562b2794f9cad7b2909a3c
|
||||
extraSetup = lib.mkIf config.documentation.man.generateCaches ''
|
||||
${makewhatis} -T utf8 ${
|
||||
lib.concatMapStringsSep " " (path: "\"$out/${path}\"") cfg.manPath
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue