1
0
Fork
You've already forked niri-nix
0
forked from bananad3v/niri-nix
A Nix flake for the niri compositor.
  • Nix 100%
2026年02月20日 13:53:09 +01:00
.forgejo/workflows fix(actions/update): Wrong action 2026年01月02日 09:43:30 +03:00
lib fix(lib/validatedConfigFor)!: remove pkgs argument as it is part of library, not user environment 2026年01月06日 11:11:27 +03:00
modules modules/home: Don't use a submodule for niri settings 2026年01月30日 19:43:16 +03:00
packages fix(packages/niri): patch the systemd service to use an absolute path to the niri executable 2026年02月20日 13:53:09 +01:00
.envrc Initial commit 2025年12月28日 18:14:30 +03:00
.gitignore Initial commit 2025年12月28日 18:14:30 +03:00
CONTRIBUTING.md meta: Drop conventional commits 2026年01月06日 13:05:53 +03:00
flake.lock chore(flake.lock): Update inputs 2026年02月16日 00:19:22 +00:00
flake.nix Merge branch 'main' of https://codeberg.org/BANanaD3V/niri-nix 2026年01月06日 13:05:56 +03:00
home-options.md modules/home: Don't use a submodule for niri settings 2026年01月30日 19:43:16 +03:00
LICENSE Initial commit 2025年12月28日 18:14:30 +03:00
nixos-options.md modules/home: Don't use a submodule for niri settings 2026年01月30日 19:43:16 +03:00
README.md fix(lib/validatedConfigFor)!: remove pkgs argument as it is part of library, not user environment 2026年01月06日 11:11:27 +03:00
VERSION feat: Add convco hook, CHANGELOG 2026年01月06日 11:50:23 +03:00

Niri Nix

A flake for configuring the Niri window manager with Nix.

The options are described in nixos-options.md and home-options.md respectfully.

Installation

To install the flake, add the following input to your flake.nix:

niri-nix = {
 url = "git+https://codeberg.org/BANanaD3V/niri-nix";
};

The flake provides both NixOS and home-manager modules.

imports = [ inputs.niri-nix.nixosModules.default ]; # For NixOS
imports = [ inputs.niri-nix.homeModules.default ]; # For home-manager

Overlays

The flake provides an overlay and a binary cache for packages. The packages are niri-unstable and xwayland-satellite-unstable.

The binary cache is located at https://niri-nix.cachix.org, the public key is niri-nix.cachix.org-1:SvFtqpDcf7Sm1SMJdby1/+Y+6f3Yt3/3PMcSTKPJNJ0=.

Niri unstable

To use niri unstable, add the overlay and the binary cache and then set programs.niri.package for the NixOS module and wayland.windowManager.niri.package for home-manager. You do not need to set the home-manager package if you're using the NixOS module to intall niri.

Important

By using the binary cache you are trusting me not to compromise your system and serve you malicious packages. The module will never automatically add the cache. The default cache priority is 41, which is below cache.nixos.org. Proceed at your own discretion.

{inputs, pkgs, ...}: {
 nix = {
 substituters = [
 "https://niri-nix.cachix.org"
 ];
 trusted-public-keys = [
 "niri-nix.cachix.org-1:SvFtqpDcf7Sm1SMJdby1/+Y+6f3Yt3/3PMcSTKPJNJ0="
 ];
 };
 nixpkgs.overlays = [ inputs.niri-nix.overlays.niri-nix ];
 programs.niri.package = pkgs.niri-unstable; 
}

NixOS module

UWSM

The NixOS module allows you to use UWSM to launch Niri. To do so, enable programs.niri.withUWSM.

XDG

The NixOS module automatically enables XDG portal configuration for you. To disable the functionality, disable programs.niri.withXDG.

home-manager module

Niri configuration

To configure niri you generally should use the provided home-manager options, wayland.windowManager.niri.settings and wayland.windowManager.niri.extraConfig. The options follow the RFC 42. This means that the options are freeform and checked during build by running niri validate. The extraConfig value is appended after settings.

You can disable validation by setting wayland.windowManager.niri.validation.enable to false.

All KDL attributes are exposed to Nix. For writing regular nodes, use the nix syntax. For arguments and properties, see below.

  1. You can set arguments by using the _args field:
output = [
 {
 _args = ["DP-0"];
 mode = "1920x1080@60";
 }
 {
 _args = ["DP-1"];
 mode = "2560x1440@60";
 }
];

This results in the following KDL config:

output"DP-0"{ mode"1920x1080@60"}output"DP-1"{ mode"2560x1440@60"}
  1. For properties you can similarly use the _props field. Let us try to extend our previous output config:
output = [
 {
 _args = ["DP-0"];
 mode = "1920x1080@60";
 position._props = {
 x = 0;
 y = 0;
 };
}
{
 _args = ["DP-1"];
 mode = "2560x1440@60";
 position._props = {
 x = 1920;
 y = 0;
 };
 }
];

The resulting config will now be as follows:

output"DP-0"{ mode"1920x1080@60" positionx=0y=0}output"DP-1"{ mode"2560x1440@60" positionx=1920y=0}
  1. For an array of children with same property names, for example the preset-column-widths, use the _children field:
layout.preset-column-widths._children = [
 {proportion = 0.33333;}
 {proportion = 0.5;}
 {proportion = 0.66667;}
 {proportion = 1.0;}
];

The resulting KDL:

layout{ preset-column-widths{ proportion0.333330 proportion0.500000 proportion0.666670 proportion1.000000}}
  1. The library also provides a way to set raw values, for example, to use regular expressions. To do so, use the _raw attribute:
window-rule = [
 {
 match = {
 _props.app-id._raw = ''r#"^org\.telegram\.desktop$"#'';
 };
 block-out-from = "screen-capture";
 }
];

This should be everything required to fully configure Niri.

For an example configuration, see the options reference

Usage without home-manager

If you do not wish to use home-manager, the flake provides a lib output containing all the necessary functions to configure Niri.

{ inputs, pkgs, ... }: let
 inherit (inputs.niri-nix.lib) validatedConfigFor mkNiriKDL;
 inherit (inputs.niri-nix.packages.${pkgs.stdenv.hostPlatform.system}) niri-unstable;
 myConfig = {
 output = [
 {
 _args = ["DP-0"];
 mode = "1920x1080@60";
 }
 {
 _args = ["DP-1"];
 mode = "2560x1440@60";
 }
 ];
 };
in {
 # Obviously replacing xdg.configFile with your own needed function.
 xdg.configFile."niri/config-validated.kdl".text = validatedConfigFor niri-unstable (mkNiriKDL myConfig); # Config example with validation (`niri validate`)
 xdg.configFile."niri/config-plain.kdl".text = mkNiriKDL myConfig; # Config example without validation
}

Credits

  • home-manager for the initial toKDL function
  • Naxdy/niri for the required home-manager systemd option and slight toKDL improvements.
  • niri-flake for some code snippets (portals, etc).