···5566 cfg = config.documentation.man.mandoc;
7788-in {
88+ toMandocOutput = output: (
99+ lib.mapAttrsToList
1010+ (
1111+ name: value:
1212+ if lib.isString value || lib.isPath value then "output ${name} ${value}"
1313+ else if lib.isInt value then "output ${name} ${builtins.toString value}"
1414+ else if lib.isBool value then lib.optionalString value "output ${name}"
1515+ else if value == null then ""
1616+ else throw "Unrecognized value type ${builtins.typeOf value} of key ${name} in mandoc output settings"
1717+ )
1818+ output
1919+ );
2020+in
2121+{
922 meta.maintainers = [ lib.maintainers.sternenseemann ];
10231124 options = {
1225 documentation.man.mandoc = {
1313- enable = lib.mkEnableOption (lib.mdDoc "mandoc as the default man page viewer");
2626+ enable = lib.mkEnableOption "mandoc as the default man page viewer";
14271528 manPath = lib.mkOption {
1629 type = with lib.types; listOf str;
1730 default = [ "share/man" ];
1831 example = lib.literalExpression "[ \"share/man\" \"share/man/fr\" ]";
1919- description = lib.mdDoc ''
2020- Change the manpath, i. e. the directories where
2121- {manpage}`man(1)`
3232+ description = ''
3333+ Change the paths included in the MANPATH environment variable,
3434+ i. e. the directories where {manpage}`man(1)`
2235 looks for section-specific directories of man pages.
2336 You only need to change this setting if you want extra man pages
2437 (e. g. in non-english languages). All values must be strings that
2538 are a valid path from the target prefix (without including it).
2626- The first value given takes priority.
3939+ The first value given takes priority. Note that this will not
4040+ add manpath directives to {manpage}`man.conf(5)`.
2741 '';
2842 };
2943···3145 type = lib.types.package;
3246 default = pkgs.mandoc;
3347 defaultText = lib.literalExpression "pkgs.mandoc";
3434- description = lib.mdDoc ''
4848+ description = ''
3549 The `mandoc` derivation to use. Useful to override
3650 configuration options used for the package.
3751 '';
3852 };
5353+5454+ settings = lib.mkOption {
5555+ description = "Configuration for {manpage}`man.conf(5)`";
5656+ default = { };
5757+ type = lib.types.submodule {
5858+ options = {
5959+ manpath = lib.mkOption {
6060+ type = with lib.types; listOf str;
6161+ default = [ ];
6262+ example = lib.literalExpression "[ \"/run/current-system/sw/share/man\" ]";
6363+ description = ''
6464+ Override the default search path for {manpage}`man(1)`,
6565+ {manpage}`apropos(1)`, and {manpage}`makewhatis(8)`. It can be
6666+ used multiple times to specify multiple paths, with the order
6767+ determining the manual page search order.
6868+ This is not recommended in favor of
6969+ {option}`documentation.man.mandoc.manPath`, but if it's needed to
7070+ specify the manpath in this way, set
7171+ {option}`documentation.man.mandoc.manPath` to an empty list (`[]`).
7272+ '';
7373+ };
7474+ output.fragment = lib.mkEnableOption ''
7575+ Omit the <!DOCTYPE> declaration and the <html>, <head>, and <body>
7676+ elements and only emit the subtree below the <body> element in HTML
7777+ output of {manpage}`mandoc(1)`. The style argument will be ignored.
7878+ This is useful when embedding manual content within existing documents.
7979+ '';
8080+ output.includes = lib.mkOption {
8181+ type = with lib.types; nullOr str;
8282+ default = null;
8383+ example = lib.literalExpression "../src/%I.html";
8484+ description = ''
8585+ A string of relative path used as a template for the output path of
8686+ linked header files (usually via the In macro) in HTML output.
8787+ Instances of `%I` are replaced with the include filename. The
8888+ default is not to present a hyperlink.
8989+ '';
9090+ };
9191+ output.indent = lib.mkOption {
9292+ type = with lib.types; nullOr int;
9393+ default = null;
9494+ description = ''
9595+ Number of blank characters at the left margin for normal text,
9696+ default of `5` for {manpage}`mdoc(7)` and `7` for
9797+ {manpage}`man(7)`. Increasing this is not recommended; it may
9898+ result in degraded formatting, for example overfull lines or ugly
9999+ line breaks. When output is to a pager on a terminal that is less
100100+ than 66 columns wide, the default is reduced to three columns.
101101+ '';
102102+ };
103103+ output.man = lib.mkOption {
104104+ type = with lib.types; nullOr str;
105105+ default = null;
106106+ example = lib.literalExpression "../html%S/%N.%S.html";
107107+ description = ''
108108+ A template for linked manuals (usually via the Xr macro) in HTML
109109+ output. Instances of ‘%N’ and ‘%S’ are replaced with the linked
110110+ manual's name and section, respectively. If no section is included,
111111+ section 1 is assumed. The default is not to present a hyperlink.
112112+ If two formats are given and a file %N.%S exists in the current
113113+ directory, the first format is used; otherwise, the second format is used.
114114+ '';
115115+ };
116116+ output.paper = lib.mkOption {
117117+ type = with lib.types; nullOr str;
118118+ default = null;
119119+ description = ''
120120+ This option is for generating PostScript and PDF output. The paper
121121+ size name may be one of `a3`, `a4`, `a5`, `legal`, or `letter`.
122122+ You may also manually specify dimensions as `NNxNN`, width by
123123+ height in millimetres. If an unknown value is encountered, letter
124124+ is used. Output pages default to letter sized and are rendered in
125125+ the Times font family, 11-point. Margins are calculated as 1/9 the
126126+ page length and width. Line-height is 1.4m.
127127+ '';
128128+ };
129129+ output.style = lib.mkOption {
130130+ type = with lib.types; nullOr path;
131131+ default = null;
132132+ description = ''
133133+ Path to the file used for an external style-sheet. This must be a
134134+ valid absolute or relative URI.
135135+ '';
136136+ };
137137+ output.toc = lib.mkEnableOption ''
138138+ In HTML output of {manpage}`mandoc(1)`, If an input file contains
139139+ at least two non-standard sections, print a table of contents near
140140+ the beginning of the output.
141141+ '';
142142+ output.width = lib.mkOption {
143143+ type = with lib.types; nullOr int;
144144+ default = null;
145145+ description = ''
146146+ The ASCII and UTF-8 output width, default is `78`. When output is a
147147+ pager on a terminal that is less than 79 columns wide, the
148148+ default is reduced to one less than the terminal width. In any case,
149149+ lines that are output in literal mode are never wrapped and may
150150+ exceed the output width.
151151+ '';
152152+ };
153153+ };
154154+ };
155155+ };
156156+157157+ extraConfig = lib.mkOption {
158158+ type = lib.types.lines;
159159+ default = "";
160160+ description = ''
161161+ Extra configuration to write to {manpage}`man.conf(5)`.
162162+ '';
163163+ };
39164 };
40165 };
41166···43168 environment = {
44169 systemPackages = [ cfg.package ];
451704646- # tell mandoc about man pages
4747- etc."man.conf".text = lib.concatMapStrings (path: ''
4848- manpath /run/current-system/sw/${path}
4949- '') cfg.manPath;
171171+ etc."man.conf".text = lib.concatStringsSep "\n" (
172172+ (map (path: "manpath ${path}") cfg.settings.manpath)
173173+ ++ (toMandocOutput cfg.settings.output)
174174+ ++ [ cfg.extraConfig ]
175175+ );
5017651177 # create mandoc.db for whatis(1), apropos(1) and man(1) -k
52178 # TODO(@sternenseemman): fix symlinked directories not getting indexed,
53179 # see: https://inbox.vuxu.org/mandoc-tech/20210906171231.GF83680@athene.usta.de/T/#e85f773c1781e3fef85562b2794f9cad7b2909a3c
54180 extraSetup = lib.mkIf config.documentation.man.generateCaches ''
5555- ${makewhatis} -T utf8 ${
181181+ for man_path in ${
56182 lib.concatMapStringsSep " " (path:
57183 "$out/" + lib.escapeShellArg path
5858- ) cfg.manPath
5959- }
184184+ ) cfg.manPath} ${lib.concatMapStringsSep " " (path:
185185+ lib.escapeShellArg path) cfg.settings.manpath
186186+ }
187187+ do
188188+ [[ -d "$man_path" ]] && ${makewhatis} -T utf8 $man_path
189189+ done
60190 '';
191191+192192+ # tell mandoc the paths containing man pages
193193+ profileRelativeSessionVariables."MANPATH" = map (path: if builtins.substring 0 1 path != "/" then "/${path}" else path) cfg.manPath;
61194 };
62195 };
63196}
-2
nixos/modules/security/sudo-rs.nix
···6677 cfg = config.security.sudo-rs;
8899- inherit (config.security.pam) enableSSHAgentAuth;
1010-119 toUserString = user: if (isInt user) then "#${toString user}" else "${user}";
1210 toGroupString = group: if (isInt group) then "%#${toString group}" else "%${group}";
1311
···3232 runHook postInstall
3333 '';
34343535+ passthru.scriptName = "mpvacious";
3636+3537 meta = with lib; {
3638 description = "Adds mpv keybindings to create Anki cards from movies and TV shows";
3739 homepage = "https://github.com/Ajatt-Tools/mpvacious";
···1313 };
14141515 scriptPath = ".";
1616- passthru.scriptName = "webui.lua";
1616+ passthru.scriptName = "webui";
17171818 meta = with lib; {
1919 description = "A web based user interface with controls for the mpv mediaplayer";