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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Purpose of this fork

I am using this main flake heavily for configuration of niri. However, I am also using the niri blur PR and am unable to configure blur at all since it isn't added. So I added a backdoor that appends text to the config.kdl without the kdl check. This is temporary, once the next niri release happens I will take down this fork.

---

This flake contains nix packages for [niri](https://github.com/YaLTeR/niri), a scrollable-tiling Wayland compositor. You can try it right now: add the binary cache with `cachix use niri` and then `nix run github:sodiboo/niri-flake`. You can also try the latest commit to the `main` branch with `nix run github:sodiboo/niri-flake#niri-unstable`.

This flake also contains NixOS and home-manager modules to install all necessary components of a working Wayland environment, and to let you manage your configuration declaratively, validating it at build-time. This ensures that your config's schema is always in sync with the installed version of niri.
Expand Down
11 changes: 10 additions & 1 deletion docs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 63 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,23 @@
config.xdg.configFile.niri-config = {
enable = cfg.finalConfig != null;
target = "niri/config.kdl";
source = validated-config-for pkgs cfg.package cfg.finalConfig;
source =
let
extraConfig = if cfg.settings != null then cfg.settings.extraConfig else "";
validatedConfig = validated-config-for pkgs cfg.package cfg.checkedConfig;
in
pkgs.runCommand "config.kdl"
{
inherit extraConfig;
passAsFile = [ "extraConfig" ];
}
''
install -Dm0644 ${validatedConfig} $out
if [ -s $extraConfigPath ]; then
printf '\n' >> $out
cat $extraConfigPath >> $out
fi
'';
};
};
nixosModules.niri =
Expand Down Expand Up @@ -568,6 +584,7 @@
checks = forAllSystems (
system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
test-nixos-for =
nixpkgs: modules:
(nixpkgs.lib.nixosSystem {
Expand Down Expand Up @@ -598,7 +615,51 @@
};
in
validated-config-for inputs.nixpkgs.legacyPackages.${system} self.packages.${system}.niri-stable
eval.config.programs.niri.finalConfig;
eval.config.programs.niri.checkedConfig;

home-extra-config-appended =
let
eval = nixpkgs.lib.evalModules {
specialArgs = {
inherit pkgs;
};
modules = [
self.homeModules.config
{
options.lib = nixpkgs.lib.mkOption {
type = nixpkgs.lib.types.attrsOf nixpkgs.lib.types.anything;
default = { };
};

options.xdg.configFile = nixpkgs.lib.mkOption {
type = nixpkgs.lib.types.attrsOf (
nixpkgs.lib.types.submodule {
options = {
enable = nixpkgs.lib.mkOption {
type = nixpkgs.lib.types.bool;
default = true;
};
target = nixpkgs.lib.mkOption {
type = nixpkgs.lib.types.str;
};
source = nixpkgs.lib.mkOption {
type = nixpkgs.lib.types.path;
};
};
}
);
default = { };
};

config.programs.niri.settings.extraConfig = "unsupported-experimental-node";
}
];
};
in
pkgs.runCommand "home-extra-config-appended" { } ''
grep -Fx unsupported-experimental-node ${eval.config.xdg.configFile.niri-config.source}
touch $out
'';

nixos-unstable = test-nixos-for nixpkgs [
self.nixosModules.niri
Expand Down
39 changes: 35 additions & 4 deletions settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3001,6 +3001,16 @@
'';
};
}

{
extraConfig = optional types.lines "" // {
description = ''
Extra KDL config to append to the generated config file.

This is not validated by niri at build time. Use this for experimental options that are not yet supported by ${fmt.code "programs.niri.settings"}.
'';
};
}
];
}
);
Expand Down Expand Up @@ -3043,6 +3053,27 @@
};

finalConfig = mkOption {
type = types.nullOr types.str;
default =
if cfg.checkedConfig != null then
cfg.checkedConfig
+ lib.optionalString (
cfg.settings != null && cfg.settings.extraConfig != ""
) "\n${cfg.settings.extraConfig}"
else
null;
readOnly = true;
defaultText = null;
description = ''
The final niri config file contents.

This is a string that reflects the document stored in ${link' "programs.niri.config"}, with ${link' "programs.niri.settings.extraConfig"} appended.

It is exposed mainly for debugging purposes, such as when you need to inspect how a certain option affects the resulting config file.
'';
};

checkedConfig = mkOption {
type = types.nullOr types.str;
default =
if builtins.isString cfg.config then
Expand All @@ -3052,13 +3083,13 @@
else
null;
readOnly = true;
internal = true;
visible = false;
defaultText = null;
description = ''
The final niri config file contents.

This is a string that reflects the document stored in ${link' "programs.niri.config"}.
The niri config file contents that should be validated at build time.

It is exposed mainly for debugging purposes, such as when you need to inspect how a certain option affects the resulting config file.
Unlike ${link' "programs.niri.finalConfig"}, this does not include ${link' "programs.niri.settings.extraConfig"}.
'';
};
};
Expand Down