1# NixOS manpages
2
3This is the collection of NixOS manpages, excluding `configuration.nix(5)`.
4
5Man pages are written in [`mdoc(7)` format](https://mandoc.bsd.lv/man/mdoc.7.html) and should be portable between mandoc and groff for rendering (though minor differences may occur, mandoc and groff seem to have slightly different spacing rules.)
6
7For previewing edited files, you can just run `man -l path/to/file.8` and you will see it rendered.
8
9Being written in `mdoc` these manpages use semantic markup. This file provides a guideline on where to apply which of the semantic elements of `mdoc`.
10
11### Command lines and arguments
12
13In any manpage, commands, flags and arguments to the *current* executable should be marked according to their semantics. Commands, flags and arguments passed to *other* executables should not be marked like this and should instead be considered as code examples and marked with `Ql`.
14
15 - Use `Fl` to mark flag arguments, `Ar` for their arguments.
16 - Repeating arguments should be marked by adding ellipses (`...`).
17 - Use `Cm` to mark literal string arguments, e.g. the `boot` command argument passed to `nixos-rebuild`.
18 - Optional flags or arguments should be marked with `Op`. This includes optional repeating arguments.
19 - Required flags or arguments should not be marked.
20 - Mutually exclusive groups of arguments should be enclosed in curly brackets, preferably created with `Bro`/`Brc` blocks.
21
22When an argument is used in an example it should be marked up with `Ar` again to differentiate it from a constant. For example, a command with a `--host name` flag that calls ssh to retrieve the host's local time would signify this thusly:
23```
24This will run
25.Ic ssh Ar name Ic time
26to retrieve the remote time.
27```
28
29### Paths, NixOS options, environment variables
30
31Constant paths should be marked with `Pa`, NixOS options with `Va`, and environment variables with `Ev`.
32
33Generated paths, e.g. `result/bin/run-hostname-vm` (where `hostname` is a variable or arguments) should be marked as `Ql` inline literals with their variable components marked appropriately.
34
35 - Taking `hostname` from an argument become `.Ql result/bin/run- Ns Ar hostname Ns -vm`
36 - Taking `hostname` from a variable otherwise defined becomes `.Ql result/bin/run- Ns Va hostname Ns -vm`
37
38### Code examples and other commands
39
40In free text names and complete invocations of other commands (e.g. `ssh` or `tar -xvf src.tar`) should be marked with `Ic`, fragments of command lines should be marked with `Ql`.
41
42Larger code blocks or those that cannot be shown inline should use indented literal display block markup for their contents, i.e.
43```
44.Bd -literal -offset indent
45...
46.Ed
47```
48Contents of code blocks may be marked up further, e.g. if they refer to arguments that will be substituted into them:
49```
50.Bd -literal -offset indent
51{
52 options.hostname = "\c
53.Ar hostname Ns \c
54";
55}
56.Ed
57```