From 05c2efb575fa644f6733c69e4da08340e5229b9d Mon Sep 17 00:00:00 2001 From: KnightArtorias Date: Tue, 19 May 2026 00:37:42 +0000 Subject: [PATCH] Niri config translation to nix --- modules/bluetooth.nix | 25 +++ modules/ckb-next.nix | 10 ++ modules/niri.nix | 357 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 392 insertions(+) create mode 100644 modules/bluetooth.nix create mode 100644 modules/ckb-next.nix create mode 100644 modules/niri.nix diff --git a/modules/bluetooth.nix b/modules/bluetooth.nix new file mode 100644 index 0000000..fa50366 --- /dev/null +++ b/modules/bluetooth.nix @@ -0,0 +1,25 @@ +{ self, inputs, ... }: { + flake.nixosModules.bluetooth = { inputs, ... }: { + hardware.bluetooth = { + enable = true; + powerOnBoot = true; + settings = { + General = { + # Shows battery charge of connected devices on supported + # Bluetooth adapters. Defaults to 'false'. + Experimental = true; + # When enabled other devices can connect faster to us, however + # the tradeoff is increased power consumption. Defaults to + # 'false'. + FastConnectable = true; + }; + Policy = { + # Enable all controllers when they are found. This includes + # adapters present on start as well as adapters that are plugged + # in later on. Defaults to 'true'. + AutoEnable = true; + }; + }; + }; + }; +} diff --git a/modules/ckb-next.nix b/modules/ckb-next.nix new file mode 100644 index 0000000..8194fe0 --- /dev/null +++ b/modules/ckb-next.nix @@ -0,0 +1,10 @@ +{ self, inputs, ... }: { + flake.nixosModules.ckb-next = { inputs, ... }: { + hardware.ckb-next = { + enable = true; + package = pkgs.ckb-next.overrideAttrs (old: { + cmakeFlags = (old.cmakeFlags or [ ]) ++ [ "-DUSE_DBUS_MENU=0" ]; + }); + }; + }; +} diff --git a/modules/niri.nix b/modules/niri.nix new file mode 100644 index 0000000..18180a9 --- /dev/null +++ b/modules/niri.nix @@ -0,0 +1,357 @@ +{ self, inputs, ... }: { + flake.wrappersModules.niri = { + config, + lib, + pkgs, + ... + }: { + options.terminal = lib.mkOption { + type = lib.types.str; + default = "alacritty"; + }; + + config = { + settings = { + prefer-no-csd = true; + + spawn-at-startup = [ + { command = [ "sh" "-c" "noctalia-shell" ]; } + { command = [ "sh" "-c" "ckb-next -b" ]; } + ]; + + screenshot-path = "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"; + + layout = { + gaps = 5; + center-focused-column = "never"; + + preset-column-widths = [ + 0.33333 + 0.5 + 0.66667 + ]; + + default-column-width = { + proportion = 0.5; + }; + + focus-ring = { + width = 1.5; + active-color = "#7aa2f7"; + inactive-color = "#a9b1d6"; + }; + + border = { + off = true; + width = 4; + active-color = "#ffc87f"; + inactive-color = "#505050"; + urgent-color = "#9b0000"; + }; + }; + + output = { + "HDMI-A-1" = { + mode = "1920x1080@60.00"; + position = { + x = 0; + y = 180; + }; + }; + + "DP-2" = { + mode = "2560x1440@144.00"; + position = { + x = 1920; + y = 0; + }; + variable-refresh-rate = true; + }; + + "DP-1" = { + mode = "1680x1050@60.00"; + position = { + x = 4480; + y = 195; + }; + }; + }; + + input = { + keyboard = { + numlock = true; + repeat-rate = 35; + repeat-delay = 500; + }; + + touchpad = { + tap = true; + natural-scroll = true; + }; + + focus-follows-mouse = { + max-scroll-amount = "0%"; + }; + }; + + window-rules = [ + { + matches = [ { app-id = "^brave-browser$"; title = "^Picture-in-Picture$"; } ]; + open-floating = true; + } + { + matches = [ + { app-id = "^org\\.keepassxc\\.KeePassXC$"; } + { app-id = "^org\\.gnome\\.World\\.Secrets$"; } + ]; + block-out-from = "screen-capture"; + } + { + geometry-corner-radius = { + radius = 12; + }; + clip-to-geometry = true; + } + { + matches = [ { app-id = "^brave-browser$"; } ]; + open-maximized = true; + } + { + matches = [ { app-id = "^vesktop$"; } ]; + open-maximized = true; + } + { + matches = [ { app-id = "^steam$"; } ]; + open-maximized = true; + } + ]; + + binds = { + "Mod+Shift+Slash".action.show-hotkey-overlay = true; + + "Mod+T" = { + hotkey-overlay-title = "Open a Terminal: alacritty"; + action.spawn = config.terminal; # Uses your custom option + }; + "Mod+D" = { + hotkey-overlay-title = "Run an Application: fuzzel"; + action.spawn = "fuzzel"; + }; + "Super+Ctrl+L" = { + hotkey-overlay-title = "Lock the Screen: swaylock"; + action.spawn = "swaylock"; + }; + "Super+Alt+S" = { + allow-when-locked = true; + action.spawn = [ "sh" "-c" "pkill orca || exec orca" ]; + }; + + # Media & Volume Controls + "XF86AudioRaiseVolume" = { + allow-when-locked = true; + action.spawn = [ "sh" "-c" "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+ -l 1.0" ]; + }; + "XF86AudioLowerVolume" = { + allow-when-locked = true; + action.spawn = [ "sh" "-c" "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-" ]; + }; + "XF86AudioMute" = { + allow-when-locked = true; + action.spawn = [ "sh" "-c" "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" ]; + }; + "XF86AudioMicMute" = { + allow-when-locked = true; + action.spawn = [ "sh" "-c" "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle" ]; + }; + "XF86AudioPlay" = { + allow-when-locked = true; + action.spawn = [ "sh" "-c" "playerctl play-pause" ]; + }; + "XF86AudioStop" = { + allow-when-locked = true; + action.spawn = [ "sh" "-c" "playerctl stop" ]; + }; + "XF86AudioPrev" = { + allow-when-locked = true; + action.spawn = [ "sh" "-c" "playerctl previous" ]; + }; + "XF86AudioNext" = { + allow-when-locked = true; + action.spawn = [ "sh" "-c" "playerctl next" ]; + }; + + # Brightness Controls + "XF86MonBrightnessUp" = { + allow-when-locked = true; + action.spawn = [ "brightnessctl" "--class=backlight" "set" "+10%" ]; + }; + "XF86MonBrightnessDown" = { + allow-when-locked = true; + action.spawn = [ "brightnessctl" "--class=backlight" "set" "10%-" ]; + }; + + # Window & Layout Navigation + "Mod+O" = { + repeat = false; + action.toggle-overview = true; + }; + "Mod+Q" = { + repeat = false; + action.close-window = true; + }; + "Mod+Left".action.focus-column-left = true; + "Mod+Down".action.focus-window-down = true; + "Mod+Up".action.focus-window-up = true; + "Mod+Right".action.focus-column-right = true; + "Mod+H".action.focus-column-left = true; + "Mod+J".action.focus-window-down = true; + "Mod+K".action.focus-window-up = true; + "Mod+L".action.focus-column-right = true; + + "Mod+Ctrl+Left".action.move-column-left = true; + "Mod+Ctrl+Down".action.move-window-down = true; + "Mod+Ctrl+Up".action.move-window-up = true; + "Mod+Ctrl+Right".action.move-column-right = true; + "Mod+Ctrl+H".action.move-column-left = true; + "Mod+Ctrl+J".action.move-window-down = true; + "Mod+Ctrl+K".action.move-window-up = true; + "Mod+Ctrl+L".action.move-column-right = true; + + "Mod+Home".action.focus-column-first = true; + "Mod+End".action.focus-column-last = true; + "Mod+Ctrl+Home".action.move-column-to-first = true; + "Mod+Ctrl+End".action.move-column-to-last = true; + + # Monitor Navigation + "Mod+Shift+Left".action.focus-monitor-left = true; + "Mod+Shift+Down".action.focus-monitor-down = true; + "Mod+Shift+Up".action.focus-monitor-up = true; + "Mod+Shift+Right".action.focus-monitor-right = true; + "Mod+Shift+H".action.focus-monitor-left = true; + "Mod+Shift+J".action.focus-monitor-down = true; + "Mod+Shift+K".action.focus-monitor-up = true; + "Mod+Shift+L".action.focus-monitor-right = true; + + "Mod+Shift+Ctrl+Left".action.move-column-to-monitor-left = true; + "Mod+Shift+Ctrl+Down".action.move-column-to-monitor-down = true; + "Mod+Shift+Ctrl+Up".action.move-column-to-monitor-up = true; + "Mod+Shift+Ctrl+Right".action.move-column-to-monitor-right = true; + "Mod+Shift+Ctrl+H".action.move-column-to-monitor-left = true; + "Mod+Shift+Ctrl+J".action.move-column-to-monitor-down = true; + "Mod+Shift+Ctrl+K".action.move-column-to-monitor-up = true; + "Mod+Shift+Ctrl+L".action.move-column-to-monitor-right = true; + + # Workspace Navigation + "Mod+Page_Down".action.focus-workspace-down = true; + "Mod+Page_Up".action.focus-workspace-up = true; + "Mod+U".action.focus-workspace-down = true; + "Mod+I".action.focus-workspace-up = true; + + "Mod+Ctrl+Page_Down".action.move-column-to-workspace-down = true; + "Mod+Ctrl+Page_Up".action.move-column-to-workspace-up = true; + "Mod+Ctrl+U".action.move-column-to-workspace-down = true; + "Mod+Ctrl+I".action.move-column-to-workspace-up = true; + + "Mod+Shift+Page_Down".action.move-workspace-down = true; + "Mod+Shift+Page_Up".action.move-workspace-up = true; + "Mod+Shift+U".action.move-workspace-down = true; + "Mod+Shift+I".action.move-workspace-up = true; + + # Scrolling / Mouse Wheel + "Mod+WheelScrollDown" = { + cooldown-ms = 150; + action.focus-workspace-down = true; + }; + "Mod+WheelScrollUp" = { + cooldown-ms = 150; + action.focus-workspace-up = true; + }; + "Mod+Ctrl+WheelScrollDown" = { + cooldown-ms = 150; + action.move-column-to-workspace-down = true; + }; + "Mod+Ctrl+WheelScrollUp" = { + cooldown-ms = 150; + action.move-column-to-workspace-up = true; + }; + + "Mod+WheelScrollRight".action.focus-column-right = true; + "Mod+WheelScrollLeft".action.focus-column-left = true; + "Mod+Ctrl+WheelScrollRight".action.move-column-right = true; + "Mod+Ctrl+WheelScrollLeft".action.move-column-left = true; + + "Mod+Shift+WheelScrollDown".action.focus-column-right = true; + "Mod+Shift+WheelScrollUp".action.focus-column-left = true; + "Mod+Ctrl+Shift+WheelScrollDown".action.move-column-right = true; + "Mod+Ctrl+Shift+WheelScrollUp".action.move-column-left = true; + + # Numbered Workspaces + "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+Ctrl+1".action.move-column-to-workspace = 1; + "Mod+Ctrl+2".action.move-column-to-workspace = 2; + "Mod+Ctrl+3".action.move-column-to-workspace = 3; + "Mod+Ctrl+4".action.move-column-to-workspace = 4; + "Mod+Ctrl+5".action.move-column-to-workspace = 5; + "Mod+Ctrl+6".action.move-column-to-workspace = 6; + "Mod+Ctrl+7".action.move-column-to-workspace = 7; + "Mod+Ctrl+8".action.move-column-to-workspace = 8; + "Mod+Ctrl+9".action.move-column-to-workspace = 9; + + # Window Layout Adjustments + "Mod+BracketLeft".action.consume-or-expel-window-left = true; + "Mod+BracketRight".action.consume-or-expel-window-right = true; + "Mod+Comma".action.consume-window-into-column = true; + "Mod+Period".action.expel-window-from-column = true; + + "Mod+R".action.switch-preset-column-width = true; + "Mod+Shift+R".action.switch-preset-window-height = true; + "Mod+Ctrl+R".action.reset-window-height = true; + "Mod+F".action.maximize-column = true; + "Mod+Shift+F".action.fullscreen-window = true; + "Mod+Ctrl+F".action.expand-column-to-available-width = true; + "Mod+C".action.center-column = true; + "Mod+Ctrl+C".action.center-visible-columns = true; + + "Mod+Minus".action.set-column-width = "-10%"; + "Mod+Equal".action.set-column-width = "+10%"; + "Mod+Shift+Minus".action.set-window-height = "-10%"; + "Mod+Shift+Equal".action.set-window-height = "+10%"; + + "Mod+V".action.toggle-window-floating = true; + "Mod+Shift+V".action.switch-focus-between-floating-and-tiling = true; + "Mod+W".action.toggle-column-tabbed-display = true; + + # Screenshots + "Print".action.screenshot = true; + "Ctrl+Print".action.screenshot-screen = true; + "Alt+Print".action.screenshot-window = true; + + # System Controls + "Mod+Escape" = { + allow-inhibiting = false; + action.toggle-keyboard-shortcuts-inhibit = true; + }; + "Mod+Shift+E".action.quit = true; + "Ctrl+Alt+Delete".action.quit = true; + "Mod+Shift+P".action.power-off-monitors = true; + }; + }; + }; + }; + + perSystem = { pkgs, ... }: { + packages.niri = inputs.wrapper-modules.wrappers.niri.wrap { + inherit pkgs; + imports = [ self.wrapperModules.niri ]; + }; + }; +}