Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

_module.args

Additional arguments passed to each module in addition to ones like lib, config, and pkgs, modulesPath.

This option is also available to all submodules. Submodules do not inherit args from their parent module, nor do they provide args to their parent module or sibling submodules. The sole exception to this is the argument name which is provided by parent modules to a submodule and contains the attribute name the submodule is bound to, or a unique generated name if it is not bound to an attribute.

Some arguments are already passed by default, of which the following cannot be changed with this option:

  • lib: The nixpkgs library.

  • config: The results of all options after merging the values from all modules together.

  • options: The options declared in all modules.

  • specialArgs: The specialArgs argument passed to evalModules.

  • All attributes of specialArgs

    Whereas option values can generally depend on other option values thanks to laziness, this does not apply to imports, which must be computed statically before anything else.

    For this reason, callers of the module system can provide specialArgs which are available during import resolution.

    For NixOS, specialArgs includes modulesPath, which allows you to import extra modules from the nixpkgs package tree without having to somehow make the module aware of the location of the nixpkgs or NixOS directories.

    { modulesPath, ... }: {
      imports = [
        (modulesPath + "/profiles/minimal.nix")
      ];
    }
    

For NixOS, the default value for this option includes at least this argument:

  • pkgs: The nixpkgs package set according to the nixpkgs.pkgs option.

Type: lazy attribute set of raw value

Default:

{ }

Declared by:

assertions.*.assertion

The thing to assert.

Type: boolean

Declared by:

assertions.*.message

The error message.

Type: string

Declared by:

icons

All predefined icons by category.

Type: attribute set of attribute set of (submodule)

Default:

{ }

Declared by:

icons.<name>.<name>.file

The icon file

Type: absolute path

Declared by:

lib

This option allows modules to define helper functions, constants, etc.

Type: attribute set of (attribute set)

Default:

{ }

Declared by:

networks

Defines logical networks that are present in your topology.

Type: attribute set of (submodule)

Default:

{ }

Declared by:

networks.<name>.cidrv4

The CIDRv4 address space of this network or null if it doesn’t use ipv4

Type: null or string

Default:

null

Declared by:

networks.<name>.cidrv6

The CIDRv6 address space of this network or null if it doesn’t use ipv6

Type: null or string

Default:

null

Declared by:

networks.<name>.icon

The icon representing this network. Must be a path to an image or a valid icon name (<category>.<name>).

Type: null or absolute path or string

Default:

null

Declared by:

networks.<name>.id

The id of this network

Type: string (read only)

Default:

"‹name›"

Declared by:

networks.<name>.name

The name of this network

Type: string

Default:

"Unnamed network '‹name›'"

Declared by:

networks.<name>.style

A style for this network, usually used to draw connections. Must be an attrset consisting of three attributes:

  • primaryColor (#rrggbb): The primary color, usually the color of edges.
  • secondaryColor (#rrggbb): The secondary color, usually the background of a dashed line and only shown when pattern != solid. Set to null for transparent.
  • pattern (solid, dashed, dotted): The pattern to use.

Type: (attribute set) or (attribute set) convertible to it

Default:

"<one of the unused predefined styles>"

Declared by:

nixosConfigurations

The list of nixos configurations to process for topology rendering. All of these must include the relevant nixos topology module.

Type: unspecified value

Default:

{ }

Declared by:

nodes

Defines nodes that are shown in the topology graph. Nodes usually correspond to nixos hosts or other devices in your network.

Type: attribute set of (submodule)

Default:

{ }

Declared by:

nodes.<name>.deviceIcon

The icon representing this node’s type. Must be a path to an image or a valid icon name (<category>.<name>). By default an icon will be selected based on the deviceType.

Type: null or absolute path or string

Default:

null

Declared by:

nodes.<name>.deviceType

The device type of the node. This can be set to anything, but some special values exist that will automatically set some other defaults, most notably the deviceIcon and renderer.preferredType.

Type: one of “nixos”, “internet”, “router”, “switch”, “device” or string

Declared by:

nodes.<name>.guestType

If the device is a guest of another device, this will tell the type of guest it is.

Type: null or one of “microvm”, “nixos-container” or string

Default:

null

Declared by:

nodes.<name>.hardware.image

An image representing this node, usually shown larger than an icon.

Type: null or absolute path

Default:

null

Declared by:

nodes.<name>.hardware.info

A single line of information about this node’s hardware. Usually the model name or a description the most important components.

Type: string

Default:

""

Declared by:

nodes.<name>.icon

The icon representing this node. Usually shown next to the name. Must be a path to an image or a valid icon name (<category>.<name>).

Type: null or absolute path or string

Default:

null

Declared by:

nodes.<name>.id

The id of this node

Type: string (read only)

Default:

"‹name›"

Declared by:

nodes.<name>.interfaces

Collects information about a specific interface of this node.

Type: attribute set of (submodule)

Default:

{ }

Declared by:

nodes.<name>.interfaces.<name>.addressFormatter

A function to format a list of addresses.

Type: function that evaluates to a(n) string

Default:

<function>

Declared by:

nodes.<name>.interfaces.<name>.addresses

The configured address(es), or a descriptive string (like DHCP).

Type: list of string

Default:

[ ]

Declared by:

nodes.<name>.interfaces.<name>.gateways

The configured gateways, if any.

Type: list of string

Default:

[ ]

Declared by:

nodes.<name>.interfaces.<name>.icon

The icon representing this interface’s type. Must be a path to an image or a valid icon name (<category>.<name>). By default an icon will be selected based on the type.

Type: null or absolute path or string

Default:

null

Declared by:

nodes.<name>.interfaces.<name>.id

The id of this interface

Type: string (read only)

Default:

"‹name›"

Declared by:

nodes.<name>.interfaces.<name>.mac

The MAC address of this interface, if known.

Type: null or string

Default:

null

Declared by:

nodes.<name>.interfaces.<name>.network

The id of the network to which this interface belongs, if any.

Type: (null or string) or (null or string) convertible to it

Default:

{
  _lazyValue = null;
}

Declared by:

nodes.<name>.interfaces.<name>.physicalConnections

A list of other node interfaces to which this node is physically connected.

Type: list of (submodule)

Default:

[ ]

Declared by:

nodes.<name>.interfaces.<name>.physicalConnections.*.interface

The other node’s interface id.

Type: string

Declared by:

nodes.<name>.interfaces.<name>.physicalConnections.*.node

The other node id.

Type: string

Declared by:

nodes.<name>.interfaces.<name>.physicalConnections.*.renderer.reverse

Whether to reverse the edge. Can be useful to affect node positioning if the layouter is directional.

Type: boolean

Default:

false

Declared by:

nodes.<name>.interfaces.<name>.renderer.hidePhysicalConnections

Whether to hide physical connections of this interface in renderings. Affects both outgoing connections defined here and incoming connections defined on other interfaces.

Usually only affects rendering of the main topology view, not network-centric views.

Type: boolean

Default:

false

Declared by:

nodes.<name>.interfaces.<name>.sharesNetworkWith

Defines a list of predicates that determine whether this interface shares its connected network with another provided local interface. The predicates take the name of another interface and returns true if our network should be shared with the given interface. It suffices if any of the predicates return true.

Sharing here means that if a network is set on this interface, it will also be set as the network for any shared interface. Setting the same predicate on multiple interfaces causes them to share a network regardless on which port the network is actually defined.

An unmanaged switch for example would set this to const true, effectively propagating the network set on one port to all other ports. Having two assigned networks within one predicate group will cause a warning to be issued.

Type: list of function that evaluates to a(n) boolean

Default:

[ ]

Declared by:

nodes.<name>.interfaces.<name>.type

The type of this interface

Type: string

Default:

"ethernet"

Declared by:

nodes.<name>.interfaces.<name>.virtual

Whether this is a virtual interface.

Type: boolean

Default:

false

Declared by:

nodes.<name>.name

The name of this node

Type: string

Default:

"<name>"

Declared by:

nodes.<name>.parent

The id of the parent node, if this node has a parent.

Type: null or string

Default:

null

Declared by:

nodes.<name>.renderer.preferredType

An optional hint to the renderer to specify whether this node should preferrably rendered as a full card, or just as an image with name. If there is no hardware image, this will usually still render a small card.

Type: one of “card”, “image”

Default:

"\"card\" # defaults to card but is also derived from the deviceType if possible."

Declared by:

nodes.<name>.services

Defines a service that is running on this node.

Type: attribute set of (submodule)

Default:

{ }

Declared by:

nodes.<name>.services.<name>.details

Additional detail sections that should be shown to the user.

Type: attribute set of (submodule)

Default:

{ }

Declared by:

nodes.<name>.services.<name>.details.<name>.name

The name of this section

Type: string (read only)

Default:

"‹name›"

Declared by:

nodes.<name>.services.<name>.details.<name>.order

The order determines how sections are ordered. Lower numbers first, default is 100.

Type: signed integer

Default:

100

Declared by:

nodes.<name>.services.<name>.details.<name>.text

The additional information to display

Type: strings concatenated with “\n”

Declared by:

nodes.<name>.services.<name>.hidden

Whether this service should be hidden from graphs

Type: boolean

Default:

false

Declared by:

nodes.<name>.services.<name>.icon

The icon for this service. Must be a path to an image or a valid icon name (<category>.<name>).

Type: null or absolute path or string

Default:

null

Declared by:

nodes.<name>.services.<name>.id

The id of this service

Type: string (read only)

Default:

"‹name›"

Declared by:

nodes.<name>.services.<name>.info

Additional high-profile information about this service, usually the url or listen address. Most likely shown directly below the name.

Type: strings concatenated with “\n”

Default:

""

Declared by:

nodes.<name>.services.<name>.name

The name of this service

Type: string

Default:

"‹name›"

Declared by:

nodes.<name>.services.<name>.serviceId

The id of the service as defined in topology.serviceRegistry.<service-id>

Type: null or string

Default:

null

Declared by:

output

The derivation containing the rendered output

Type: absolute path (read only)

Default:

config.renderers.elk.output

Declared by:

renderer

Which renderer to use for the default output. Available options: elk svg

Type: null or one of “elk”, “svg”

Default:

"elk"

Declared by:

renderers.elk.output

The derivation containing the rendered output

Type: absolute path (read only)

Declared by:

renderers.elk.overviews.networks.enable

Include a networks overview in the main output

Type: boolean

Default:

true

Declared by:

renderers.elk.overviews.services.enable

Include a services overview in the main output

Type: boolean

Default:

true

Declared by:

renderers.svg.output

The derivation containing the rendered output

Type: absolute path (read only)

Declared by:

serviceRegistry

A registry of known services containing all metadata (name, icon, visibility flags) plus extractor-specific discovery, info, and details functions used by the graph renderers. Services refer to an entry with serviceId, and the services extractor adds a service for each entry whose nixos settings match a NixOS host’s configuration.

Each NixOS host has its own registry under topology.serviceRegistry, which applies to the services of that host. The registry in the global topology module only applies to nodes that aren’t NixOS hosts, such as routers. To change an entry for all NixOS hosts, define it in a NixOS module that all of them import.

Type: attribute set of (submodule)

Default:

{ }

Declared by:

serviceRegistry.<name>.hidden

Whether this service should be hidden from graphs

Type: boolean

Default:

false

Declared by:

serviceRegistry.<name>.icon

The icon for this service. Must be a path to an image or a valid icon name (<category>.<name>).

Type: null or absolute path or string

Default:

null

Declared by:

serviceRegistry.<name>.name

The name of this service

Type: string

Default:

""

Declared by:

serviceRegistry.<name>.nixos

NixOS-specific metadata for this service

Type: submodule

Default:

{ }

Declared by:

serviceRegistry.<name>.nixos.enabled

A function that determines if this service is enabled. The function is called with an attribute set containing cfg (the value at path, or the instance’s value if instances is set), instance (the name of the instance, or null) and config (the whole NixOS configuration). Always accept further arguments with ..., as more may be added in the future.

Type: function

Default:

{ cfg, ... }: cfg.enable or false

Declared by:

serviceRegistry.<name>.nixos.detailsFn

A function that returns additional detail sections that should be shown to the user. The function is called with an attribute set containing cfg (the value at path, or the instance’s value if instances is set), instance (the name of the instance, or null) and config (the whole NixOS configuration). Always accept further arguments with ..., as more may be added in the future.

Type: function

Default:

_: { }

Declared by:

serviceRegistry.<name>.nixos.iconFn

An optional function that dynamically computes the service icon. Takes precedence over the static icon when set. The function is called with an attribute set containing cfg (the value at path, or the instance’s value if instances is set), instance (the name of the instance, or null) and config (the whole NixOS configuration). Always accept further arguments with ..., as more may be added in the future.

Type: null or function

Default:

null

Declared by:

serviceRegistry.<name>.nixos.infoFn

A function that returns a string with additional high-profile information about this service, usually the url or listen address. Most likely shown directly below the name. The function is called with an attribute set containing cfg (the value at path, or the instance’s value if instances is set), instance (the name of the instance, or null) and config (the whole NixOS configuration). Always accept further arguments with ..., as more may be added in the future.

Type: function

Default:

_: ""

Declared by:

serviceRegistry.<name>.nixos.instances

Whether the value at path is an attribute set of instances, such as services.restic.backups. If set, one service is created for each instance with the id <service-id>-<instance>, and the functions below are called for each instance.

Type: boolean

Default:

false

Example:

true

Declared by:

serviceRegistry.<name>.nixos.nameFn

An optional function that dynamically computes the service name. Takes precedence over the static name when set. The function is called with an attribute set containing cfg (the value at path, or the instance’s value if instances is set), instance (the name of the instance, or null) and config (the whole NixOS configuration). Always accept further arguments with ..., as more may be added in the future.

Type: null or function

Default:

null

Declared by:

serviceRegistry.<name>.nixos.path

The NixOS option path for this service. Services whose path doesn’t exist in a host’s nixpkgs are skipped.

Type: null or string

Default:

null

Example:

"services.grafana"

Declared by:

serviceRegistry.<name>.serviceId

The unique identifier for this service. Defaults to the attribute name.

Type: string

Default:

"‹name›"

Declared by: