1# Contributing to this documentation {#chap-contributing}
2
3The sources of the Nixpkgs manual are in the [doc](https://github.com/NixOS/nixpkgs/tree/master/doc) subdirectory of the Nixpkgs repository. The manual is still partially written in DocBook but it is progressively being converted to [Markdown](#sec-contributing-markup).
4
5You can quickly check your edits with `make`:
6
7```ShellSession
8$ cd /path/to/nixpkgs/doc
9$ nix-shell
10[nix-shell]$ make
11```
12
13If you experience problems, run `make debug` to help understand the docbook errors.
14
15After making modifications to the manual, it's important to build it before committing. You can do that as follows:
16
17```ShellSession
18$ cd /path/to/nixpkgs/doc
19$ nix-shell
20[nix-shell]$ make clean
21[nix-shell]$ nix-build .
22```
23
24If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`.
25
26## Syntax {#sec-contributing-markup}
27
28As per [RFC 0072](https://github.com/NixOS/rfcs/pull/72), all new documentation content should be written in [CommonMark](https://commonmark.org/) Markdown dialect.
29
30Additional syntax extensions are available, all of which can be used in NixOS option documentation. The following extensions are currently used:
31
32- []{#ssec-contributing-markup-anchors}
33 Explicitly defined **anchors** on headings, to allow linking to sections. These should be always used, to ensure the anchors can be linked even when the heading text changes, and to prevent conflicts between [automatically assigned identifiers](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/auto_identifiers.md).
34
35 It uses the widely compatible [header attributes](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md) syntax:
36
37 ```markdown
38 ## Syntax {#sec-contributing-markup}
39 ```
40
41 ::: {.note}
42 NixOS option documentation does not support headings in general.
43 :::
44
45- []{#ssec-contributing-markup-anchors-inline}
46 **Inline anchors**, which allow linking arbitrary place in the text (e.g. individual list items, sentences…).
47
48 They are defined using a hybrid of the link syntax with the attributes syntax known from headings, called [bracketed spans](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/bracketed_spans.md):
49
50 ```markdown
51 - []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`.
52 ```
53
54- []{#ssec-contributing-markup-automatic-links}
55 If you **omit a link text** for a link pointing to a section, the text will be substituted automatically. For example, `[](#chap-contributing)` will result in [](#chap-contributing).
56
57 This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing).
58
59- []{#ssec-contributing-markup-inline-roles}
60 If you want to link to a man page, you can use `` {manpage}`nix.conf(5)` ``, which will turn into {manpage}`nix.conf(5)`. The references will turn into links when a mapping exists in {file}`doc/manpage-urls.json`.
61
62 A few markups for other kinds of literals are also available:
63
64 - `` {command}`rm -rfi` `` turns into {command}`rm -rfi`
65 - `` {env}`XDG_DATA_DIRS` `` turns into {env}`XDG_DATA_DIRS`
66 - `` {file}`/etc/passwd` `` turns into {file}`/etc/passwd`
67 - `` {option}`networking.useDHCP` `` turns into {option}`networking.useDHCP`
68 - `` {var}`/etc/passwd` `` turns into {var}`/etc/passwd`
69
70 These literal kinds are used mostly in NixOS option documentation.
71
72 This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#roles-an-in-line-extension-point). Though, the feature originates from [reStructuredText](https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-manpage) with slightly different syntax.
73
74- []{#ssec-contributing-markup-admonitions}
75 **Admonitions**, set off from the text to bring attention to something.
76
77 It uses pandoc’s [fenced `div`s syntax](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md):
78
79 ```markdown
80 ::: {.warning}
81 This is a warning
82 :::
83 ```
84
85 which renders as
86
87 > ::: {.warning}
88 > This is a warning.
89 > :::
90
91 The following are supported:
92
93 - [`caution`](https://tdg.docbook.org/tdg/5.0/caution.html)
94 - [`important`](https://tdg.docbook.org/tdg/5.0/important.html)
95 - [`note`](https://tdg.docbook.org/tdg/5.0/note.html)
96 - [`tip`](https://tdg.docbook.org/tdg/5.0/tip.html)
97 - [`warning`](https://tdg.docbook.org/tdg/5.0/warning.html)
98
99- []{#ssec-contributing-markup-definition-lists}
100 [**Definition lists**](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/definition_lists.md), for defining a group of terms:
101
102 ```markdown
103 pear
104 : green or yellow bulbous fruit
105
106 watermelon
107 : green fruit with red flesh
108 ```
109
110 which renders as
111
112 > pear
113 > : green or yellow bulbous fruit
114 >
115 > watermelon
116 > : green fruit with red flesh
117
118For contributing to the legacy parts, please see [DocBook: The Definitive Guide](https://tdg.docbook.org/) or the [DocBook rocks! primer](https://web.archive.org/web/20200816233747/https://docbook.rocks/).