Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,25 @@ But you can also pass it a string:
}
```

or set `programs.niri.config = null;` to prevent this module from generating a config file. By default, it will generate a config file based on `programs.niri.settings` if it is not `null`.
By default its value is derived from `programs.niri.settings`.

For debugging (primarily development of this flake i guess), there is also `programs.niri.finalConfig` which is always a string (or null) and represents the final config file that will be end up in your config directory.
You can also combine option-based configuration with manual one by
setting `programs.niri.extraConfig`. It has the same type as
`programs.niri.config` and defaults to `null`.

If both `programs.niri.config` and `programs.niri.extraConfig` are
`null`, this module will not generate a config file at all.

For debugging (primarily development of this flake i guess), there is also `programs.niri.finalConfig` which is always a string (or null) and represents the final rendered config file that will end up in your config directory.

> [!note]
> `programs.niri.settings` is not guaranteed to be compatible with niri versions other than the two provided by this flake. \
> In particular, this means that i do not guarantee compatibility with the one from nixpkgs at all times (i.e. when nixpkgs is lagging behind due to build failures or other reasons). \
> In practice, you will not have an issue with this unless you are running old versions of niri that are 2 or more releases behind. I will try my best not to break compatibility with nixpkgs.
>
> This does not apply to `programs.niri.config` as it is inherently version-agnostic and still provides build-time validation.
> This does not apply to `programs.niri.config` and `programs.niri.extraConfig` as those are inherently version-agnostic.
>
> The final config is always validated at build time.

# Stylix

Expand Down
40 changes: 33 additions & 7 deletions settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3036,21 +3036,47 @@

- When this is null, no config file is generated.
- When this is a string, it is assumed to be the config file contents.
- When this is kdl document, it is serialized to a string before being used as the config file contents.
- When this is a KDL document, it is serialized to a string before being used as the config file contents.

By default, this is a KDL document that reflects the settings in ${link' "programs.niri.settings"}.
By default, this is a KDL document that reflects the settings in ${link' "programs.niri.settings"} plus ${link' "programs.niri.extraConfig"}.
'';
};

extraConfig = mkOption {
type = types.nullOr (types.either types.str kdl.types.kdl-document);
default = null;
description = ''
A verbatim section to be appended to the niri config file.

- When this is null, nothing will be appended.
- When this is a string, it is assumed to be literal config file contents.
- When this is a KDL document, it is serialized to a string before being appended to the config file.
'';
};

finalConfig = mkOption {
type = types.nullOr types.str;
default =
if builtins.isString cfg.config then
cfg.config
else if cfg.config != null then
kdl.serialize.nodes cfg.config
let
flatten =
value:
if builtins.isString value then
value
else if value != null then
kdl.serialize.nodes value
else
null;

mainRendered = flatten cfg.config;
extraRendered = flatten cfg.extraConfig;
in
if mainRendered == null then
extraRendered
else if extraRendered == null then
mainRendered
else
null;
mainRendered + "\n" + extraRendered;

readOnly = true;
defaultText = null;
description = ''
Expand Down