Files
lux/modules/capabilities/niri/default.nix
T
2026-09-22 21:44:35 +02:00

151 lines
3.9 KiB
Nix

{
config,
...
}:
let
hmModules = config.flake.modules.homeManager;
in
{
flake.modules.nixos.niri =
{ ... }:
{
home-manager.sharedModules = [ hmModules.niri ];
programs.niri.enable = true;
};
flake.modules.homeManager.niri =
{
config,
lib,
pkgs,
...
}:
let
swapMonitorWorkspaces = import ./_support/shortcuts.nix { inherit pkgs; };
renameWorkspace = pkgs.writeShellApplication {
name = "rename-workspace";
runtimeInputs = [
pkgs.niri
pkgs.zenity
];
text = ''
name=$(zenity --entry --title="Workspace name" --text="Name this workspace (empty clears its name):") || exit 0
if [[ -n "$name" ]]; then
niri msg action set-workspace-name "$name"
else
niri msg action unset-workspace-name
fi
'';
};
machine = config.facts.machine;
in
{
home = {
sessionVariables.NIXOS_OZONE_WL = "1";
packages =
with pkgs;
[
playerctl
brightnessctl
wireplumber
wtype
]
++ [
swapMonitorWorkspaces
renameWorkspace
];
};
wayland.windowManager.niri = {
enable = true;
settings = {
_children =
lib.mapAttrsToList (name: display: {
output = {
_args = [ name ];
position._props = {
inherit (display) x y;
};
}
// lib.optionalAttrs display.primary {
"focus-at-startup" = { };
}
// lib.optionalAttrs (display.scale != null) {
inherit (display) scale;
}
// lib.optionalAttrs (display.width != null) {
mode = "${toString display.width}x${toString display.height}@${toString display.refresh}";
};
}) machine.displays
++ map (command: { spawn-at-startup = command; }) config.desktop.autostart
++ [
{
window-rule = {
geometry-corner-radius = [
10.0
10.0
10.0
10.0
];
clip-to-geometry = true;
};
}
];
environment.DISPLAY = ":0";
prefer-no-csd = { };
hotkey-overlay.skip-at-startup = { };
screenshot-path = "${config.xdg.userDirs.pictures}/screenshots/%Y-%m-%dT%H:%M:%S.png";
animations.slowdown = 0.6;
cursor = lib.mkIf config.home.pointerCursor.enable {
xcursor-size = config.home.pointerCursor.size;
xcursor-theme = config.home.pointerCursor.name;
hide-after-inactive-ms = 3000;
hide-when-typing = { };
};
layout = {
always-center-single-column = { };
gaps = 14;
focus-ring.off = { };
default-column-width.proportion = 1. / 2.;
border.width = 3;
};
debug.honor-xdg-activation-with-invalid-serial = true;
gestures.hot-corners.off = { };
input = {
focus-follows-mouse = { };
mouse."accel-speed" = 0.4;
keyboard = {
repeat-delay = 300;
repeat-rate = 50;
xkb.options = "caps:escape";
};
touchpad = {
tap = { };
dwt = { };
natural-scroll = { };
};
};
binds = import ./_support/bindings.nix {
inherit (config.desktop.commands)
browser
launcher
terminal
;
swapMonitorWorkspaces = lib.getExe swapMonitorWorkspaces;
handy = lib.getExe pkgs.handy;
};
};
};
};
}