From ebaa206a8146957354c9427feae6a90d0763fcf5 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Wed, 12 Mar 2025 02:00:13 +0100 Subject: [PATCH] Switch to niri - Episode 1: beginnings --- common.nix | 4 +- flake.lock | 132 +++++++++++++++++- flake.nix | 11 +- hosts/denkbrett/modules/input.nix | 2 - modules/desktop-environment/dm.nix | 2 +- modules/desktop-environment/home/default.nix | 2 + .../desktop-environment/home/niri/binds.nix | 70 ++++++++++ .../desktop-environment/home/niri/default.nix | 44 ++++++ .../desktop-environment/home/niri/input.nix | 14 ++ .../home/niri/screenshot.nix | 10 ++ .../desktop-environment/home/niri/style.nix | 54 +++++++ .../home/niri/xwayland-sat.nix | 8 ++ modules/desktop-environment/home/terminal.nix | 1 + modules/desktop/creative.nix | 2 + 14 files changed, 343 insertions(+), 13 deletions(-) create mode 100644 modules/desktop-environment/home/niri/binds.nix create mode 100644 modules/desktop-environment/home/niri/default.nix create mode 100644 modules/desktop-environment/home/niri/input.nix create mode 100644 modules/desktop-environment/home/niri/screenshot.nix create mode 100644 modules/desktop-environment/home/niri/style.nix create mode 100644 modules/desktop-environment/home/niri/xwayland-sat.nix diff --git a/common.nix b/common.nix index 764bee3..c72d791 100644 --- a/common.nix +++ b/common.nix @@ -2,9 +2,9 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). { - config, pkgs, lib, + niri, lix-module, rs-programs, ... @@ -28,7 +28,7 @@ with builtins; { "nodejs-16.20.0" ]; }; - overlays = [rs-programs]; + overlays = [rs-programs niri.overlays.niri]; }; environment = { diff --git a/flake.lock b/flake.lock index 02ae1c6..ba64528 100644 --- a/flake.lock +++ b/flake.lock @@ -194,6 +194,62 @@ "type": "path" } }, + "niri": { + "inputs": { + "niri-stable": "niri-stable", + "niri-unstable": "niri-unstable", + "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable", + "xwayland-satellite-stable": "xwayland-satellite-stable", + "xwayland-satellite-unstable": "xwayland-satellite-unstable" + }, + "locked": { + "lastModified": 1741589763, + "narHash": "sha256-F0LYLKX2jaUIs+/sPYjSLVtVfgsfwsdkbb5WoMkSlmQ=", + "owner": "sodiboo", + "repo": "niri-flake", + "rev": "aab4ffcc1d43e8a0fb02f84c2a88c25fd0528110", + "type": "github" + }, + "original": { + "owner": "sodiboo", + "repo": "niri-flake", + "type": "github" + } + }, + "niri-stable": { + "flake": false, + "locked": { + "lastModified": 1740117926, + "narHash": "sha256-mTTHA0RAaQcdYe+9A3Jx77cmmyLFHmRoZdd8RpWa+m8=", + "owner": "YaLTeR", + "repo": "niri", + "rev": "b94a5db8790339cf9134873d8b490be69e02ac71", + "type": "github" + }, + "original": { + "owner": "YaLTeR", + "ref": "v25.02", + "repo": "niri", + "type": "github" + } + }, + "niri-unstable": { + "flake": false, + "locked": { + "lastModified": 1741582754, + "narHash": "sha256-lS1bn4Eq94xbOfkxq2RbpohqME99H7k/8i0yq62I6ms=", + "owner": "YaLTeR", + "repo": "niri", + "rev": "b351f6ff220560d96a260d8dd3ad794000923481", + "type": "github" + }, + "original": { + "owner": "YaLTeR", + "repo": "niri", + "type": "github" + } + }, "nixos-hardware": { "locked": { "lastModified": 1687903496, @@ -220,9 +276,10 @@ "type": "github" }, "original": { - "id": "nixpkgs", + "owner": "NixOS", "ref": "nixos-unstable", - "type": "indirect" + "repo": "nixpkgs", + "type": "github" } }, "nixpkgs-lib": { @@ -238,6 +295,22 @@ } }, "nixpkgs-stable": { + "locked": { + "lastModified": 1741445498, + "narHash": "sha256-F5Em0iv/CxkN5mZ9hRn3vPknpoWdcdCyR0e4WklHwiE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "52e3095f6d812b91b22fb7ad0bfc1ab416453634", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable_2": { "locked": { "lastModified": 1741445498, "narHash": "sha256-F5Em0iv/CxkN5mZ9hRn3vPknpoWdcdCyR0e4WklHwiE=", @@ -268,6 +341,21 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1741379970, + "narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1726937504, "narHash": "sha256-bvGoiQBvponpZh8ClUcmJ6QnsNKw0EMrCQJARK3bI1c=", @@ -290,9 +378,10 @@ "home-manager": "home-manager", "lix-module": "lix-module", "mac-brcm-fw": "mac-brcm-fw", + "niri": "niri", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs", - "nixpkgs-stable": "nixpkgs-stable", + "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable_2", "nixpkgs-unstable-small": "nixpkgs-unstable-small", "typst-within": "typst-within" } @@ -378,7 +467,7 @@ "crane": "crane_2", "fenix": "fenix_2", "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "rust-manifest": "rust-manifest", "systems": "systems_2" }, @@ -395,6 +484,39 @@ "repo": "typst", "type": "github" } + }, + "xwayland-satellite-stable": { + "flake": false, + "locked": { + "lastModified": 1739246919, + "narHash": "sha256-/hBM43/Gd0/tW+egrhlWgOIISeJxEs2uAOIYVpfDKeU=", + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "rev": "44590a416d4a3e8220e19e29e0b6efe64a80315d", + "type": "github" + }, + "original": { + "owner": "Supreeeme", + "ref": "v0.5.1", + "repo": "xwayland-satellite", + "type": "github" + } + }, + "xwayland-satellite-unstable": { + "flake": false, + "locked": { + "lastModified": 1741140299, + "narHash": "sha256-Y2bPO92Yg5HcH5ORvrVOQb4wRGEapGEteHXGtNvboxk=", + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "rev": "10cb041a80bb815cc1789cfa305923f1f9e3713d", + "type": "github" + }, + "original": { + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index c4c0b17..1943853 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,7 @@ nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs-stable.url = "nixpkgs/nixos-24.11"; nixpkgs-unstable-small.url = "nixpkgs/nixos-unstable-small"; + niri.url = "github:sodiboo/niri-flake"; typst-within = { url = "github:schrottkatze/typst"; }; @@ -40,6 +41,7 @@ home-manager, nixos-hardware, mac-brcm-fw, + niri, fenix, crane, ... @@ -90,10 +92,11 @@ nixosConfigurations = { monosodium-glutamate-g = nixpkgs.lib.nixosSystem { specialArgs = { - inherit inputs pkgs-unstable-small pkgs-stable rs-programs lix-module; + inherit inputs pkgs-unstable-small pkgs-stable rs-programs lix-module niri; }; system = "x86_64-linux"; modules = [ + inputs.niri.nixosModules.niri ./hosts/monosodium-glutamate-g/configuration.nix home-manager.nixosModules.home-manager { @@ -115,10 +118,11 @@ }; denkbrett = nixpkgs.lib.nixosSystem { specialArgs = { - inherit inputs pkgs-unstable-small pkgs-stable rs-programs lix-module; + inherit inputs pkgs-unstable-small pkgs-stable rs-programs lix-module niri; }; system = "x86_64-linux"; modules = [ + inputs.niri.nixosModules.niri ./hosts/denkbrett/configuration.nix home-manager.nixosModules.home-manager { @@ -140,10 +144,11 @@ }; potatobook-g = nixpkgs.lib.nixosSystem { specialArgs = { - inherit inputs pkgs-unstable-small rs-programs lix-module; + inherit inputs pkgs-unstable-small rs-programs lix-module niri; }; system = "x86_64-linux"; modules = [ + inputs.niri.nixosModules.niri "${mac-brcm-fw}" ./hosts/potatobook-g/configuration.nix home-manager.nixosModules.home-manager diff --git a/hosts/denkbrett/modules/input.nix b/hosts/denkbrett/modules/input.nix index a6116f5..db9b4db 100644 --- a/hosts/denkbrett/modules/input.nix +++ b/hosts/denkbrett/modules/input.nix @@ -26,6 +26,4 @@ device = "TPPS/2 IBM TrackPoint"; sensitivity = 256; }; - - services.libinput.touchpad.tapping = true; } diff --git a/modules/desktop-environment/dm.nix b/modules/desktop-environment/dm.nix index ebdb023..9fe88a6 100644 --- a/modules/desktop-environment/dm.nix +++ b/modules/desktop-environment/dm.nix @@ -20,7 +20,7 @@ in enable = cfg.autoLogin.enable; user = "jade"; }; - defaultSession = "sway"; + defaultSession = "niri"; sessionPackages = [ pkgs.sway ]; diff --git a/modules/desktop-environment/home/default.nix b/modules/desktop-environment/home/default.nix index 558291e..0b48b10 100644 --- a/modules/desktop-environment/home/default.nix +++ b/modules/desktop-environment/home/default.nix @@ -1,4 +1,5 @@ {...}: { + programs.niri.enable = true; home-manager.users.jade = {...}: { imports = [ ./notifications.nix @@ -8,6 +9,7 @@ ./panels ./xmonad ./sway + ./niri ]; services.gpg-agent = { diff --git a/modules/desktop-environment/home/niri/binds.nix b/modules/desktop-environment/home/niri/binds.nix new file mode 100644 index 0000000..35e5895 --- /dev/null +++ b/modules/desktop-environment/home/niri/binds.nix @@ -0,0 +1,70 @@ +{...}: { + programs.niri.settings.binds = { + # spawn terminal + "Mod+Return".action.spawn = "kitty"; + "Mod+Return".repeat = false; + "Mod+D".action.spawn = ["wofi" "-S" "drun" "--allow-images"]; + "Mod+D".repeat = false; + + "Mod+Shift+E".action.quit = []; + "Mod+Shift+Q".action.close-window = []; + + "Mod+Shift+Slash".action.show-hotkey-overlay = []; + + # window/columns controls + "Mod+H".action.focus-column-left = []; + "Mod+J".action.focus-window-down = []; + "Mod+K".action.focus-window-up = []; + "Mod+L".action.focus-column-right = []; + "Mod+Ctrl+H".action.move-column-left = []; + "Mod+Ctrl+J".action.move-window-down = []; + "Mod+Ctrl+K".action.move-window-up = []; + "Mod+Ctrl+L".action.move-column-right = []; + + # monitor controls + "Mod+Shift+H".action.focus-monitor-left = []; + "Mod+Shift+J".action.focus-monitor-down = []; + "Mod+Shift+K".action.focus-monitor-up = []; + "Mod+Shift+L".action.focus-monitor-right = []; + "Mod+Shift+Ctrl+H".action.move-column-to-monitor-left = []; + "Mod+Shift+Ctrl+J".action.move-column-to-monitor-down = []; + "Mod+Shift+Ctrl+K".action.move-column-to-monitor-up = []; + "Mod+Shift+Ctrl+L".action.move-column-to-monitor-right = []; + + # workspace controls + "Mod+P".action.focus-workspace-up = []; + "Mod+N".action.focus-workspace-down = []; + "Mod+Ctrl+P".action.move-column-to-workspace-up = []; + "Mod+Ctrl+N".action.move-column-to-workspace-down = []; + "Mod+1".action.focus-workspace = 1; + "Mod+2".action.focus-workspace = 2; + "Mod+3".action.focus-workspace = 3; + "Mod+4".action.focus-workspace = 4; + "Mod+5".action.focus-workspace = 5; + "Mod+6".action.focus-workspace = 6; + "Mod+7".action.focus-workspace = 7; + "Mod+8".action.focus-workspace = 8; + "Mod+9".action.focus-workspace = 9; + "Mod+Shift+1".action.move-column-to-workspace = 1; + "Mod+Shift+2".action.move-column-to-workspace = 2; + "Mod+Shift+3".action.move-column-to-workspace = 3; + "Mod+Shift+4".action.move-column-to-workspace = 4; + "Mod+Shift+5".action.move-column-to-workspace = 5; + "Mod+Shift+6".action.move-column-to-workspace = 6; + "Mod+Shift+7".action.move-column-to-workspace = 7; + "Mod+Shift+8".action.move-column-to-workspace = 8; + "Mod+Shift+9".action.move-column-to-workspace = 9; + + # column editing stuffs + "Mod+BracketLeft".action.consume-or-expel-window-left = []; + "Mod+BracketRight".action.consume-or-expel-window-right = []; + "Mod+F".action.maximize-column = []; + "Mod+Shift+F".action.fullscreen-window = []; + "Mod+C".action.center-column = []; + "Mod+Minus".action.set-column-width = "-5%"; + "Mod+Equal".action.set-column-width = "+5%"; + "Mod+Shift+Minus".action.set-window-height = "-10%"; + "Mod+Shift+Equal".action.set-window-height = "+10%"; + "Mod+W".action.toggle-column-tabbed-display = []; + }; +} diff --git a/modules/desktop-environment/home/niri/default.nix b/modules/desktop-environment/home/niri/default.nix new file mode 100644 index 0000000..7dea436 --- /dev/null +++ b/modules/desktop-environment/home/niri/default.nix @@ -0,0 +1,44 @@ +{pkgs, ...}: { + imports = [ + ./xwayland-sat.nix + ./screenshot.nix + ./input.nix + ./binds.nix + ./style.nix + ]; + programs.niri.settings = { + outputs."eDP-1" = { + scale = 1.0; + }; + + spawn-at-startup = [ + { + command = ["eww" "open-many" "topBar" "bottomBar"]; + } + { + command = [ + "${pkgs.swaybg}/bin/swaybg" + "-i" + "${../xmonad/wallpaper/wallpaper.jpg}" + "-m" + "fill" + ]; + } + ]; + + window-rules = [ + # TODO: privacy screen rules + # { + # geometry-corner-radius = let val = 1.; in { + # bottom-left = val; + # bottom-right = val; + # top-left = val; + # top-right = val; + # }; + # clip-to-geometry = true; + # } + ]; + + environment.ELECTRON_OZONE_PLATFORM_HINT = "auto"; + }; +} diff --git a/modules/desktop-environment/home/niri/input.nix b/modules/desktop-environment/home/niri/input.nix new file mode 100644 index 0000000..9d8ca1f --- /dev/null +++ b/modules/desktop-environment/home/niri/input.nix @@ -0,0 +1,14 @@ +{...}: { + programs.niri.settings.input = { + keyboard = { + xkb = { + layout = "us"; + variant = "altgr-intl"; + }; + }; + touchpad = { + tap = true; + natural-scroll = true; + }; + }; +} diff --git a/modules/desktop-environment/home/niri/screenshot.nix b/modules/desktop-environment/home/niri/screenshot.nix new file mode 100644 index 0000000..e39a0e9 --- /dev/null +++ b/modules/desktop-environment/home/niri/screenshot.nix @@ -0,0 +1,10 @@ +{pkgs, ...}: { + programs.niri.settings = { + screenshot-path = "~/Pictures/screenshots/%Y-%m-%dT%H:%M:%S.png"; + binds = { + "Print".action.screenshot = []; + "Ctrl+Print".action.screenshot-screen = []; + "Alt+Print".action.screenshot-window = []; + }; + }; +} diff --git a/modules/desktop-environment/home/niri/style.nix b/modules/desktop-environment/home/niri/style.nix new file mode 100644 index 0000000..0511b67 --- /dev/null +++ b/modules/desktop-environment/home/niri/style.nix @@ -0,0 +1,54 @@ +{...}: { + programs.niri.settings = { + cursor = { + theme = "phinger-cursors"; + size = 16; + hide-when-typing = true; + hide-after-inactive-ms = 2500; + }; + + layout = { + gaps = 15; + focus-ring.enable = false; + border = { + enable = true; + width = 3; + inactive.gradient = { + from = "#f69ecf"; + to = "#ff9a56"; + in' = "oklch shorter hue"; + relative-to = "window"; + angle = 135; + }; + active.gradient = { + from = "#f69ecf"; + to = "#5bcefa"; + in' = "oklch shorter hue"; + relative-to = "window"; + angle = 135; + }; + }; + center-focused-column = "never"; + empty-workspace-above-first = false; + tab-indicator = { + hide-when-single-tab = true; + active.color = "#5bcefa"; + inactive.color = "#3c3836"; + gap = 1; + width = 3; + position = "left"; + gaps-between-tabs = 0; + }; + }; + + window-rules = [{ + geometry-corner-radius = let val = 1.; in { + bottom-left = val; + bottom-right = val; + top-left = val; + top-right = val; + }; + clip-to-geometry = true; + }]; + }; +} diff --git a/modules/desktop-environment/home/niri/xwayland-sat.nix b/modules/desktop-environment/home/niri/xwayland-sat.nix new file mode 100644 index 0000000..4846b11 --- /dev/null +++ b/modules/desktop-environment/home/niri/xwayland-sat.nix @@ -0,0 +1,8 @@ +{pkgs, ...}: { + programs.niri.settings = { + spawn-at-startup = [ + {command = ["${pkgs.xwayland-satellite}/bin/xwayland-satellite"];} + ]; + environment.DISPLAY = ":0"; + }; +} diff --git a/modules/desktop-environment/home/terminal.nix b/modules/desktop-environment/home/terminal.nix index 9a41eea..5b6427b 100644 --- a/modules/desktop-environment/home/terminal.nix +++ b/modules/desktop-environment/home/terminal.nix @@ -30,6 +30,7 @@ foreground = color15; background = "#1d2021"; confirm_os_window_close = 0; + hide_window_decorations = true; }; }; home.sessionVariables = { diff --git a/modules/desktop/creative.nix b/modules/desktop/creative.nix index 648a5da..32a2c3d 100644 --- a/modules/desktop/creative.nix +++ b/modules/desktop/creative.nix @@ -5,6 +5,8 @@ }: { home-manager.users.jade = {pkgs, ...}: { home.packages = with pkgs; [ + pastel + audacity krita gimp