Files
nix-config-ryan4yin/home/linux/gui/niri/default.nix
Ryan Yin 29760ddb27 refactor: update niri, write config in kdl, remove niri-flake (#237)
• Updated input 'nixpkgs':
  → 'github:NixOS/nixpkgs/0254eab410b90ef2420c1059f908ae777e3b02f9?narHash=sha256-/US2Ei9JHXHVBAxV4FX49Q7H5s4UNBrIiOA6Xjzgq44%3D' (2025-12-06)

• Updated input 'home-manager':
    'github:nix-community/home-manager/f4cb25928fafa9ae68660fe71f730fc820a59028?narHash=sha256-5xOuutXM7UPTUcn3uDAD8UlPQsXmqPrX81cXoDOAGcA%3D' (2025-11-26)
  → 'github:nix-community/home-manager/89c9508bbe9b40d36b3dc206c2483ef176f15173?narHash=sha256-rB45jv4uwC90vM9UZ70plfvY/2Kdygs%2BzlQ07dGQFk4%3D' (2025-12-17)

• Updated input 'nixpkgs-master':
    'github:nixos/nixpkgs/6812bcfd614abedbdb3f68d7b6554eda6ca3e014?narHash=sha256-sNF/PZcuzYBHKRBkerEiPf5mkZM15A3fWD%2BlqpwKc60%3D' (2025-12-15)
  → 'github:nixos/nixpkgs/e50ab9bb181f9fb3ce00e7a6007c70ddaa007203?narHash=sha256-acPMRCAPgPykzkwATwD1EfF7xgmbraAvIJyCeR6bKxc%3D' (2025-12-18)

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2025-12-18 19:56:46 -06:00

69 lines
2.3 KiB
Nix

{
pkgs,
config,
lib,
...
}@args:
let
cfg = config.modules.desktop.niri;
in
{
options.modules.desktop.niri = {
enable = lib.mkEnableOption "niri compositor";
};
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
home.packages = with pkgs; [
# Niri v25.08 will create X11 sockets on disk, export $DISPLAY, and spawn `xwayland-satellite` on-demand when an X11 client connects
xwayland-satellite
];
xdg.configFile =
let
mkSymlink = config.lib.file.mkOutOfStoreSymlink;
confPath = "${config.home.homeDirectory}/nix-config/home/linux/gui/niri/conf";
in
{
"niri/config.kdl".source = mkSymlink "${confPath}/config.kdl";
"niri/keybindings.kdl".source = mkSymlink "${confPath}/keybindings.kdl";
"niri/spawn-at-startup.kdl".source = mkSymlink "${confPath}/spawn-at-startup.kdl";
"niri/windowrules.kdl".source = mkSymlink "${confPath}/windowrules.kdl";
};
systemd.user.services.niri-flake-polkit = {
Unit = {
Description = "PolicyKit Authentication Agent provided by niri-flake";
After = [
"graphical-session.target"
];
Wants = [ "graphical-session-pre.target" ];
};
Install.WantedBy = [ "niri.service" ];
Service = {
Type = "simple";
ExecStart = "${pkgs.kdePackages.polkit-kde-agent-1}/libexec/polkit-kde-authentication-agent-1";
Restart = "on-failure";
RestartSec = 1;
TimeoutStopSec = 10;
};
};
# NOTE: this executable is used by greetd to start a wayland session when system boot up
# with such a vendor-no-locking script, we can switch to another wayland compositor without modifying greetd's config in NixOS module
home.file.".wayland-session" = {
source = pkgs.writeScript "init-session" ''
# trying to stop a previous niri session
systemctl --user is-active niri.service && systemctl --user stop niri.service
# and then we start a new one
/run/current-system/sw/bin/niri-session
'';
executable = true;
};
}
]
);
}