From c744867b5adc417748f6ed6fdb17cb6e4c6fc46b Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 14 Jan 2025 15:05:32 +0100 Subject: ... --- accounts/gkleen@sif/niri/default.nix | 117 +++++++++++++++++++++++++++++++---- accounts/gkleen@sif/niri/waybar.nix | 16 ++--- accounts/gkleen@sif/systemd.nix | 14 ----- flake.lock | 42 +++++-------- flake.nix | 7 ++- hosts/sif/default.nix | 5 +- system-profiles/core/default.nix | 2 +- system-profiles/niri-unstable.nix | 11 ++++ 8 files changed, 145 insertions(+), 69 deletions(-) create mode 100644 system-profiles/niri-unstable.nix diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 6a8d10a0..b6165487 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix @@ -1,10 +1,35 @@ -{ config, pkgs, lib, ... }: +{ config, hostConfig, pkgs, lib, ... }: let niri = config.programs.niri.package; terminal = lib.getExe config.programs.kitty.package; lightctl = lib.getExe' config.services.avizo.package "lightctl"; volumectl = lib.getExe' config.services.avizo.package "volumectl"; dunstctl = lib.getExe' config.services.dunst.package "dunstctl"; + loginctl = lib.getExe' hostConfig.systemd.package "loginctl"; + systemctl = lib.getExe' hostConfig.systemd.package "systemctl"; + + focus-or-spawn = pkgs.writeShellApplication { + name = "focus-or-spawn"; + runtimeInputs = [ niri pkgs.gojq pkgs.gnugrep ]; + text = '' + app_id="$1" + shift + workspace_name="$1" + shift + + niri msg action move-workspace-to-monitor --output "$(niri msg -j workspaces | jq -r '.[] | select(.is_focused) | .output')" "$workspace_name" + + while IFS=$'\n' read -r window_json; do + if jq -r '.app_id' <<<"$window_json" | grep -q "$app_id"; then + niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")" + exit 0 + fi + done < <(niri msg -j windows | jq -c '.[]') + + exec "$@" + ''; + }; + focus-or-spawn-action = app_id: workspace_name: config.lib.niri.actions.spawn (lib.getExe focus-or-spawn) (lib.escapeShellArg app_id) (lib.escapeShellArg workspace_name); in { imports = [ ./waybar.nix @@ -21,7 +46,9 @@ in { Service = { Type = "notify"; NotifyAccess = "all"; - ExecStart = lib.getExe pkgs.xwayland-satellite-unstable; + Environment = [ "DISPLAY=:0" ]; + ExecStart = ''${lib.getExe pkgs.xwayland-satellite-unstable} ''${DISPLAY}''; + ExecStartPre = "${systemctl} --user import-environment DISPLAY"; StandardOutput = "journal"; }; Install = { @@ -29,16 +56,44 @@ in { }; }; + services.swayidle = { + events = [ + { event = "after-resume"; command = "${lib.getExe niri} msg action power-on-monitors"; } + ]; + timeouts = [ + { timeout = 300; + command = "${lib.getExe niri} msg action power-off-monitors"; + } + ]; + }; + programs.niri.settings = { prefer-no-csd = true; screenshot-path = "${config.home.homeDirectory}/screenshots"; + hotkey-overlay.skip-at-startup = true; + input = { keyboard.xkb = { - layout = "us,"; + layout = "us,us"; variant = "dvp,"; options = "compose:caps,grp:win_space_toggle"; }; + + workspace-auto-back-and-forth = true; + # focus-follows-mouse.enable = true; + warp-mouse-to-focus = true; + }; + + outputs = { + "Samsung Display Corp. 0x4141 Unknown" = { + scale = 1.5; + position = { x = 0; y = 0; }; + }; + "Ancor Communications Inc ASUS PB287Q 0x0000DD9B" = { + scale = 1.5; + position = { x = 2560; y = 0; }; + }; }; environment = { @@ -48,9 +103,40 @@ in { SDL_VIDEODRIVER = "wayland"; }; + layout = { + gaps = 8; + struts = { left = 8; right = 8; top = 0; bottom = 0; }; + focus-ring = { + width = 2; + }; + empty-workspace-above-first = true; + }; + cursor.hide-when-typing = true; + workspaces = { + "01".name = "pwctl"; + }; + + window-rules = [ + { + geometry-corner-radius = + let + allCorners = r: { bottom-left = r; bottom-right = r; top-left = r; top-right = r; }; + in allCorners 8.; + clip-to-geometry = true; + open-focused = false; + } + { + matches = [ { app-id = "^com\.saivert\.pwvucontrol$"; } ]; + open-on-workspace = "pwctl"; + open-focused = true; + } + ]; + binds = with config.lib.niri.actions; { + "Mod+Slash".action = show-hotkey-overlay; + "Mod+Return".action = spawn terminal; "Mod+Q".action = close-window; "Mod+D".action = spawn (lib.getExe config.programs.fuzzel.package); @@ -79,17 +165,20 @@ in { "Mod+G".action = focus-workspace-down; "Mod+C".action = focus-workspace-up; - "Mod+Control+G".action = move-column-to-workspace-down; - "Mod+Control+C".action = move-column-to-workspace-up; + "Mod+Shift+G".action = move-column-to-workspace-down; + "Mod+Shift+C".action = move-column-to-workspace-up; - "Mod+Shift+G".action = move-workspace-down; - "Mod+Shift+C".action = move-workspace-up; + "Mod+Shift+Control+G".action = move-workspace-down; + "Mod+Shift+Control+C".action = move-workspace-up; - "Mod+M".action = consume-window-into-column; - "Mod+W".action = expel-window-from-column; + "Mod+M".action = consume-or-expel-window-left; + "Mod+W".action = consume-or-expel-window-right; - "Mod+F".action = maximize-column; - "Mod+Shift+F".action = fullscreen-window; + "Mod+R".action = switch-preset-column-width; + "Mod+Shift+R".action = switch-preset-window-height; + "Mod+F".action = center-column; + "Mod+Shift+F".action = maximize-column; + "Mod+Shift+Ctrl+F".action = fullscreen-window; "Mod+Space".action = switch-focus-between-floating-and-tiling; "Mod+Shift+Space".action = toggle-window-floating; @@ -103,6 +192,10 @@ in { action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors"; allow-when-locked = true; }; + "Mod+Shift+L" = { + action = spawn loginctl "lock-session"; + }; + "Mod+Shift+E".action = quit; "XF86MonBrightnessUp" = { action = spawn lightctl "-d" "-e4" "-n1" "up"; @@ -133,6 +226,8 @@ in { "Mod+Shift+Semicolon".action = spawn dunstctl "close-all"; "Mod+Period".action = spawn dunstctl "context"; "Mod+Comma".action = spawn dunstctl "history-pop"; + + "Mod+Alt+A".action = focus-or-spawn-action "^com\.saivert\.pwvucontrol$" "pwctl" "pwvucontrol"; }; }; }; diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix index 1a25b581..2d00c6d8 100644 --- a/accounts/gkleen@sif/niri/waybar.nix +++ b/accounts/gkleen@sif/niri/waybar.nix @@ -80,9 +80,7 @@ exec = "${lib.getExe pkgs.worktime} today"; tooltip = false; }; - "niri/workspaces" = { - all-outputs = true; - }; + "niri/workspaces" = {}; "niri/window" = { separate-outputs = true; icon = true; @@ -166,9 +164,7 @@ modules-center = [ "niri/window" ]; modules-right = [ "clock" ]; - "niri/workspaces" = { - all-outputs = false; - }; + "niri/workspaces" = {}; "niri/window" = { separate-outputs = true; icon = true; @@ -215,13 +211,11 @@ } #workspaces button { - color: @grey; - } - #workspaces button.hosting-monitor { color: @white; + padding: 2px 5px; } - #workspaces button.visible { - color: @blue; + #workspaces button.empty { + color: @grey; } #workspaces button.active { color: @green; diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix index c8400c28..119d8cc3 100644 --- a/accounts/gkleen@sif/systemd.nix +++ b/accounts/gkleen@sif/systemd.nix @@ -204,20 +204,6 @@ in { WatchdogSec = "2s"; }; }; - polkit-gnome-authentication-agent-1 = { - Install = { - WantedBy = ["graphical-session.target"]; - }; - Unit = { - PartOf = ["graphical-session.target"]; - Requires = ["graphical-session-pre.target"]; - After = ["graphical-session-pre.target"]; - }; - Service = { - ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; - Restart = "on-failure"; - }; - }; gtklock = { Unit = { Requisite = ["graphical-session.target"]; diff --git a/flake.lock b/flake.lock index ac52bba4..27a157d5 100644 --- a/flake.lock +++ b/flake.lock @@ -389,17 +389,19 @@ "inputs": { "niri-stable": "niri-stable", "niri-unstable": "niri-unstable", - "nixpkgs": "nixpkgs_2", + "nixpkgs": [ + "nixpkgs" + ], "nixpkgs-stable": "nixpkgs-stable_2", "xwayland-satellite-stable": "xwayland-satellite-stable", "xwayland-satellite-unstable": "xwayland-satellite-unstable" }, "locked": { - "lastModified": 1736840959, - "narHash": "sha256-po6B6ZkwtYI1BNIm5BR+JZ0HHKKNAnB+Dlr6BXCat3U=", + "lastModified": 1736855225, + "narHash": "sha256-2+ayH/0B37BLPJy4thO1titHIrVCoDdCtdnl0CyV8kc=", "owner": "sodiboo", "repo": "niri-flake", - "rev": "d775188e23f94b2f73e939414b808fc2b9ebad73", + "rev": "b013bedcff63b5cdbb9cd9841ac339361fc5cfcc", "type": "github" }, "original": { @@ -429,15 +431,15 @@ "niri-unstable": { "flake": false, "locked": { - "lastModified": 1736836910, - "narHash": "sha256-jpyL3/lVeqbcXVOHoSPgXgIbJ9vZtiCDMSvZL0UyCgQ=", - "owner": "YaLTeR", + "lastModified": 1736861309, + "narHash": "sha256-RSCoXyngYF+7apD5pRq6lZfRbl8vHIUVI57bbihA5Ew=", + "owner": "gkleen", "repo": "niri", - "rev": "36076d5279f349a32814dea91ca8f4dee61d5b08", + "rev": "80a7ee2971b2d43622f68dcdc3233ae8365338f6", "type": "github" }, "original": { - "owner": "YaLTeR", + "owner": "gkleen", "repo": "niri", "type": "github" } @@ -675,22 +677,6 @@ } }, "nixpkgs_2": { - "locked": { - "lastModified": 1736701207, - "narHash": "sha256-jG/+MvjVY7SlTakzZ2fJ5dC3V1PrKKrUEOEE30jrOKA=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ed4a395ea001367c1f13d34b1e01aa10290f67d6", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { "locked": { "lastModified": 1736798957, "narHash": "sha256-qwpCtZhSsSNQtK4xYGzMiyEDhkNzOCz/Vfu4oL2ETsQ=", @@ -706,7 +692,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_3": { "locked": { "lastModified": 1681303793, "narHash": "sha256-JEdQHsYuCfRL2PICHlOiH/2ue3DwoxUX7DJ6zZxZXFk=", @@ -829,7 +815,7 @@ "flake-compat": "flake-compat_4", "flake-utils": "flake-utils_2", "gitignore": "gitignore_3", - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_3", "nixpkgs-stable": "nixpkgs-stable_4" }, "locked": { @@ -887,7 +873,7 @@ "nix-index-database": "nix-index-database", "nixVirt": "nixVirt", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_2", "nixpkgs-eostre": "nixpkgs-eostre", "nixpkgs-pgbackrest": "nixpkgs-pgbackrest", "nixpkgs-stable": "nixpkgs-stable_3", diff --git a/flake.nix b/flake.nix index 816fd499..47c03f23 100644 --- a/flake.nix +++ b/flake.nix @@ -189,6 +189,10 @@ owner = "sodiboo"; repo = "niri-flake"; ref = "main"; + inputs = { + nixpkgs.follows = "nixpkgs"; + niri-unstable.url = "github:gkleen/niri"; + }; }; }; @@ -275,9 +279,10 @@ mkAccountModule = dir: path: accountName: let userName = accountUserName accountName; + hostName = accountHostName accountName; in overrideModule (import (dir + "/${path}")) - (inputs: inputs // { inherit userName; }) + (inputs: inputs // { inherit userName hostName; }) (outputs: { _file = dir + "/${path}"; } // outputs // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); diff --git a/hosts/sif/default.nix b/hosts/sif/default.nix index 09d43109..6dc6f3a9 100644 --- a/hosts/sif/default.nix +++ b/hosts/sif/default.nix @@ -13,8 +13,7 @@ in { imports = with flake.nixosModules.systemProfiles; [ ./hw.nix ./mail ./libvirt - tmpfs-root bcachefs initrd-all-crypto-modules default-locale openssh rebuild-machines - networkmanager + tmpfs-root bcachefs initrd-all-crypto-modules default-locale openssh rebuild-machines niri-unstable networkmanager flakeInputs.nixos-hardware.nixosModules.lenovo-thinkpad-p1 flakeInputs.impermanence.nixosModules.impermanence flakeInputs.nixVirt.nixosModules.default @@ -506,7 +505,7 @@ in { "10-regreet"."/var/cache/regreet/cache.toml".C.argument = toString ((pkgs.formats.toml {}).generate "cache.toml" { last_user = "gkleen"; - user_to_last_sess.gkleen = "niri"; + user_to_last_sess.gkleen = "Niri"; }); }; diff --git a/system-profiles/core/default.nix b/system-profiles/core/default.nix index d60507b0..b85aea4e 100644 --- a/system-profiles/core/default.nix +++ b/system-profiles/core/default.nix @@ -181,7 +181,7 @@ in { programs.ssh.internallyManaged = mkForce true; } ]; - extraSpecialArgs = { inherit flake flakeInputs path; }; + extraSpecialArgs = { inherit flake flakeInputs path; hostConfig = config; }; }; sops = mkIf hasSops { diff --git a/system-profiles/niri-unstable.nix b/system-profiles/niri-unstable.nix new file mode 100644 index 00000000..3a8b393d --- /dev/null +++ b/system-profiles/niri-unstable.nix @@ -0,0 +1,11 @@ +{ config, pkgs, lib, ... }: +{ + config = { + programs.niri.package = lib.mkDefault pkgs.niri-unstable; + home-manager.sharedModules = [ + { + programs.niri.package = lib.mkDefault config.programs.niri.package; + } + ]; + }; +} -- cgit v1.2.3