···7788```ShellSession
99$ cd /path/to/nixpkgs
1010+$ $EDITOR doc/nixos/manual/... # edit the manual
1011$ nix-build nixos/release.nix -A manual.x86_64-linux
1112```
1213···14151516There's also [a convenient development daemon](https://nixos.org/manual/nixpkgs/unstable/#sec-contributing-devmode).
16171717-**Contributing to the man pages**
1818+The above instructions don't deal with the appendix of available `configuration.nix` options, and the manual pages related to NixOS. These are built, and written in a different location and in a different format, as explained in the next sections.
1919+2020+## Contributing to the `configuration.nix` options documentation {#sec-contributing-options}
2121+2222+The documentation for all the different `configuration.nix` options is automatically generated by reading the `description`s of all the NixOS options defined at `nixos/modules/`. If you want to improve such `description`, find it in the `nixos/modules/` directory, and edit it and open a pull request.
2323+2424+To see how your changes render on the web, run again:
2525+2626+```ShellSession
2727+$ nix-build nixos/release.nix -A manual.x86_64-linux
2828+```
18291919-The man pages are written in [DocBook] which is XML.
3030+And you'll see the changes to the appendix in the path `result/share/doc/nixos/options.html`.
20312121-To see what your edits look like:
3232+You can also build only the `configuration.nix(5)` manual page, via:
22332334```ShellSession
2435$ cd /path/to/nixpkgs
2525-$ nix-build nixos/release.nix -A manpages.x86_64-linux
3636+$ nix-build nixos/release.nix -A nixos-configuration-reference-manpage.x86_64-linux
2637```
27382828-You can then read the man page you edited by running
3939+And observe the result via:
29403041```ShellSession
3131-$ man --manpath=result/share/man nixos-rebuild # Replace nixos-rebuild with the command whose manual you edited
4242+$ man --local-file result/share/man/man5/configuration.nix.5
4343+```
4444+4545+If you're on a different architecture that's supported by NixOS (check file `nixos/release.nix` on Nixpkgs' repository) then replace `x86_64-linux` with the architecture. `nix-build` will complain otherwise, but should also tell you which architecture you have + the supported ones.
4646+4747+## Contributing to `nixos-*` tools' manpages {#sec-contributing-nixos-tools}
4848+4949+The manual pages for the tools available in the installation image can be found in Nixpkgs by running (e.g for `nixos-rebuild`):
5050+5151+```ShellSession
5252+$ git ls | grep nixos-rebuild.8
5353+```
5454+5555+Man 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 (except for minor differences, notably different spacing rules.)
5656+5757+For a preview, run `man --local-file path/to/file.8`.
5858+5959+Being written in `mdoc`, these manpages use semantic markup. This following subsections provides a guideline on where to apply which semantic elements.
6060+6161+### Command lines and arguments {#ssec-contributing-nixos-tools-cli-and-args}
6262+6363+In 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`.
6464+6565+- Use `Fl` to mark flag arguments, `Ar` for their arguments.
6666+- Repeating arguments should be marked by adding an ellipsis (spelled with periods, `...`).
6767+- Use `Cm` to mark literal string arguments, e.g. the `boot` command argument passed to `nixos-rebuild`.
6868+- Optional flags or arguments should be marked with `Op`. This includes optional repeating arguments.
6969+- Required flags or arguments should not be marked.
7070+- Mutually exclusive groups of arguments should be enclosed in curly brackets, preferably created with `Bro`/`Brc` blocks.
7171+7272+When 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` option that calls ssh to retrieve the host's local time would signify this thusly:
7373+```
7474+This will run
7575+.Ic ssh Ar name Ic time
7676+to retrieve the remote time.
7777+```
7878+7979+### Paths, NixOS options, environment variables {#ssec-contributing-nixos-tools-options-and-environment}
8080+8181+Constant paths should be marked with `Pa`, NixOS options with `Va`, and environment variables with `Ev`.
8282+8383+Generated 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.
8484+8585+ - When `hostname` refers to an argument, it becomes `.Ql result/bin/run- Ns Ar hostname Ns -vm`
8686+ - When `hostname` refers to a variable, it becomes `.Ql result/bin/run- Ns Va hostname Ns -vm`
8787+8888+### Code examples and other commands {#ssec-contributing-nixos-tools-code-examples}
8989+9090+In 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`.
9191+9292+Larger code blocks or those that cannot be shown inline should use indented literal display block markup for their contents, i.e.
9393+9494+```
9595+.Bd -literal -offset indent
9696+...
9797+.Ed
3298```
33993434-If you're on a different architecture that's supported by NixOS (check nixos/release.nix) then replace `x86_64-linux` with the architecture.
3535-`nix-build` will complain otherwise, but should also tell you which architecture you have + the supported ones.
100100+Contents of code blocks may be marked up further, e.g. if they refer to arguments that will be substituted into them:
361013737-[DocBook]: https://en.wikipedia.org/wiki/DocBook
102102+```
103103+.Bd -literal -offset indent
104104+{
105105+ config.networking.hostname = "\c
106106+.Ar hostname Ns \c
107107+";
108108+}
109109+.Ed
110110+```
···11-# NixOS manpages
22-33-This is the collection of NixOS manpages, excluding `configuration.nix(5)`.
44-55-Man 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.)
66-77-For previewing edited files, you can just run `man -l path/to/file.8` and you will see it rendered.
88-99-Being written in `mdoc` these manpages use semantic markup. This file provides a guideline on where to apply which of the semantic elements of `mdoc`.
1010-1111-### Command lines and arguments
1212-1313-In 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`.
1414-1515- - Use `Fl` to mark flag arguments, `Ar` for their arguments.
1616- - Repeating arguments should be marked by adding ellipses (`...`).
1717- - Use `Cm` to mark literal string arguments, e.g. the `boot` command argument passed to `nixos-rebuild`.
1818- - Optional flags or arguments should be marked with `Op`. This includes optional repeating arguments.
1919- - Required flags or arguments should not be marked.
2020- - Mutually exclusive groups of arguments should be enclosed in curly brackets, preferably created with `Bro`/`Brc` blocks.
2121-2222-When 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:
2323-```
2424-This will run
2525-.Ic ssh Ar name Ic time
2626-to retrieve the remote time.
2727-```
2828-2929-### Paths, NixOS options, environment variables
3030-3131-Constant paths should be marked with `Pa`, NixOS options with `Va`, and environment variables with `Ev`.
3232-3333-Generated 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.
3434-3535- - Taking `hostname` from an argument become `.Ql result/bin/run- Ns Ar hostname Ns -vm`
3636- - Taking `hostname` from a variable otherwise defined becomes `.Ql result/bin/run- Ns Va hostname Ns -vm`
3737-3838-### Code examples and other commands
3939-4040-In 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`.
4141-4242-Larger code blocks or those that cannot be shown inline should use indented literal display block markup for their contents, i.e.
4343-```
4444-.Bd -literal -offset indent
4545-...
4646-.Ed
4747-```
4848-Contents of code blocks may be marked up further, e.g. if they refer to arguments that will be substituted into them:
4949-```
5050-.Bd -literal -offset indent
5151-{
5252- options.hostname = "\c
5353-.Ar hostname Ns \c
5454-";
5555-}
5656-.Ed
5757-```