Manual directives

You can declare Nix objects manually by using the following directives.

Use these directives when generating from Nix code isn’t possible or if you want to develop a custom documentation generator.

See also

Manual declarations for more manual usage examples.

.. nix:option:: name

Describes a option from the NixOS module system.

For example:

:::{nix:option} service.my-service.enable
My option description
:::

Is rendered as:

service.my-service.enable

My option description

Options

:type: (text)

The option type, for example list of string.

:read-only:

Add this option of the option is read-only.

:declaration: (text)

A link to the source code. See the nixdomain_linkcode_resolve configuration to generate a [source] link.

Other standard domain options are supported, see the Sphinx domain Basic Markup documentation.

.. nix:package:: name

Describes a Nix package.

Use field-lists after the description to describe the package’s metadata

For example:

:::{nix:package} myProject.myPackage
My package description

:version: `0.0.0-rc1`
:license: `EUPL-1.2`
:::

Will be rendered as:

myProject.myPackage

My package description

Version:

0.0.0-rc1

License:

EUPL-1.2

Options

:declaration: (text)

A link to the source code. See the nixdomain_linkcode_resolve configuration to generate a [source] link.

Other standard domain options are supported, see the Sphinx domain Basic Markup documentation.

.. nix:function:: name

Describes a Nix function.

Use field-lists after the description to describe function parameter, their types, the return value, etc.

For example:

:::{nix:function} lib.myFunction
My function description

:param int a: a number
:param int b: another number
:returns: the sum of those two numbers
:rtype: int
:::

Will be rendered as:

lib.myFunction

My function description

Parameters:
  • a (int) – a number

  • b (int) – another number

Returns:

the sum of those two numbers

Return type:

int

Options

:declaration: (text)

A link to the source code. See the nixdomain_linkcode_resolve configuration to generate a [source] link.

Other standard domain options are supported, see the Sphinx domain Basic Markup documentation.