Skip to main content
Available since version 25.11
You can include other files at the top level of the config.
Included files have the same structure as the main config file. Settings from included files will be merged with the settings from the main config file. Included config files can in turn include more files. All included files are watched for changes, and the config live-reloads when any of them change.
Includes work only at the top level of the config:

Positionality

Includes are positional. They will override options set prior to them. Window rules from included files will be inserted at the position of the include line.

Example: Overriding Settings

The end result:
  • The border color is green (from colors.kdl)
  • The overview backdrop color is red (it was set after colors.kdl)

Example: Window Rules Position

This is equivalent to:

Optional Includes

Available since next release
By default, including a nonexistent file will cause an error. You can allow nonexistent includes by setting optional=true:
When an optional include file is missing, niri will emit a warning in the logs on every config reload. This reminds you that the file is missing while still loading the config successfully.The optional file is still watched for changes, so if you create it later, the config will automatically reload and apply the new settings.
Note that optional only affects whether a missing file causes an error. If the file exists but contains invalid syntax or other errors, those errors will still cause a parsing failure.

Merging Behavior

Most config sections are merged between includes, meaning that you can set only a few properties, and only those properties will change.

Standard Merging

Multipart Sections

Multipart sections like window-rule, output, or workspace are inserted as is without merging:

Binds

binds will override previously-defined conflicting keys:

Flags

Most flags can be disabled with false:

Non-merging Sections

Some sections where the contents represent a combined structure are not merged. Examples are struts, preset-column-widths, individual subsections in animations, pointing device sections in input.

Border Special Case

There’s one special case that differs between the main config and included configs.Writing layout { border {} } in an included config does nothing (since no properties are changed). However, writing the same in the main config will enable the border, i.e. it’s equivalent to layout { border { on; } }.
So, if you want to move your layout configuration from the main config to a separate file, remember to add on to the border section:
The reason for this special case is historical: back when borders were added, there were no on flags, so writing the border {} section would enable the border, with an explicit off to disable it. Many people likely have this part of the default config embedded in their configs now, so changing how it works would cause confusion.

Use Cases

Separate Color Schemes

Shared Bindings

Device-Specific Settings