From 55817044e6d76c6c829be497c62645d18d8596a7 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Tue, 23 Apr 2024 18:17:06 +0300 Subject: [PATCH] modules: add river window manager --- flake.lock | 28 +++++- flake.nix | 5 + hosts/asus-gl553vd/configuration.nix | 2 +- hosts/asus-gl553vd/users/jan.nix | 2 +- .../configs/window-manager/default.nix | 3 +- .../window-manager/hyprland/default.nix | 3 +- .../configs/window-manager/river/default.nix | 94 +++++++++++++++++++ .../programs/terminals/wezterm.nix | 2 +- .../nixos/configs/window-manager/default.nix | 1 + .../nixos/configs/window-manager/river.nix | 21 +++++ 10 files changed, 152 insertions(+), 9 deletions(-) create mode 100644 modules/home-manager/configs/window-manager/river/default.nix create mode 100644 modules/nixos/configs/window-manager/river.nix diff --git a/flake.lock b/flake.lock index fbd3e32..d4c7b89 100644 --- a/flake.lock +++ b/flake.lock @@ -248,6 +248,27 @@ "type": "github" } }, + "home-manager-unstable": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713818326, + "narHash": "sha256-aw3xbVPJauLk/bbrlakIYxKpeuMWzA2feGrkIpIuXd8=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "67de98ae6eed5ad6f91b1142356d71a87ba97f21", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "home-manager", + "type": "github" + } + }, "home-manager_2": { "inputs": { "nixpkgs": [ @@ -255,11 +276,11 @@ ] }, "locked": { - "lastModified": 1710888565, - "narHash": "sha256-s9Hi4RHhc6yut4EcYD50sZWRDKsugBJHSbON8KFwoTw=", + "lastModified": 1712386041, + "narHash": "sha256-dA82pOMQNnCJMAsPG7AXG35VmCSMZsJHTFlTHizpKWQ=", "owner": "nix-community", "repo": "home-manager", - "rev": "f33900124c23c4eca5831b9b5eb32ea5894375ce", + "rev": "d6bb9f934f2870e5cbc5b94c79e9db22246141ff", "type": "github" }, "original": { @@ -674,6 +695,7 @@ "flake-utils": "flake-utils_2", "hardware": "hardware", "home-manager": "home-manager_2", + "home-manager-unstable": "home-manager-unstable", "lan-mouse": "lan-mouse", "myneovim": "myneovim", "nil": "nil", diff --git a/flake.nix b/flake.nix index 30c8860..20928a2 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,10 @@ url = "github:nix-community/home-manager/release-23.11"; inputs.nixpkgs.follows = "nixpkgs"; }; + home-manager-unstable = { + url = "github:nix-community/home-manager/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; wired = { url = "github:Toqozz/wired-notify"; @@ -140,6 +144,7 @@ ./modules/home-manager inputs.wired.homeManagerModules.default inputs.lan-mouse.homeManagerModules.default + "${inputs.home-manager-unstable}/modules/services/window-managers/river.nix" ]; } ]; diff --git a/hosts/asus-gl553vd/configuration.nix b/hosts/asus-gl553vd/configuration.nix index 7cee4fa..78d4906 100644 --- a/hosts/asus-gl553vd/configuration.nix +++ b/hosts/asus-gl553vd/configuration.nix @@ -13,7 +13,7 @@ local.window-manager = { xmonad.enable = false; - hyprland.enable = true; + river.enable = true; }; ################################################################################ diff --git a/hosts/asus-gl553vd/users/jan.nix b/hosts/asus-gl553vd/users/jan.nix index 9829279..1ff6e13 100644 --- a/hosts/asus-gl553vd/users/jan.nix +++ b/hosts/asus-gl553vd/users/jan.nix @@ -9,7 +9,7 @@ in home-manager.users.jan = { local.window-manager = { - hyprland.enable = true; + river.enable = true; polybar.enable = false; xmonad.enable = false; diff --git a/modules/home-manager/configs/window-manager/default.nix b/modules/home-manager/configs/window-manager/default.nix index 20e5290..3c5eeee 100644 --- a/modules/home-manager/configs/window-manager/default.nix +++ b/modules/home-manager/configs/window-manager/default.nix @@ -3,7 +3,8 @@ { imports = [ ./polybar.nix - ./xmonad ./hyprland + ./river + ./xmonad ]; } diff --git a/modules/home-manager/configs/window-manager/hyprland/default.nix b/modules/home-manager/configs/window-manager/hyprland/default.nix index bad721e..9e88bdd 100644 --- a/modules/home-manager/configs/window-manager/hyprland/default.nix +++ b/modules/home-manager/configs/window-manager/hyprland/default.nix @@ -7,13 +7,12 @@ let in { options.local.window-manager.hyprland = with lib; { - enable = mkEnableOption "hyperland window manager"; + enable = mkEnableOption "hyprland window manager"; }; config = lib.mkIf cfg.enable { home.packages = with pkgs.unstable; [ wl-clipboard - wlsunset dmenu-wayland ]; diff --git a/modules/home-manager/configs/window-manager/river/default.nix b/modules/home-manager/configs/window-manager/river/default.nix new file mode 100644 index 0000000..2349a33 --- /dev/null +++ b/modules/home-manager/configs/window-manager/river/default.nix @@ -0,0 +1,94 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.local.window-manager.river; + + pow = n: exp: + if exp == 1 then n + else if exp == 0 then 1 + else n * pow n (exp - 1); + + tile-cmd = c: ''send-layout-cmd rivertile "${c}"''; +in +{ + options.local.window-manager.river = with lib; { + enable = mkEnableOption "river window manager"; + }; + + config = lib.mkIf cfg.enable { + home.packages = with pkgs.unstable; [ + wl-clipboard + dmenu-wayland + ]; + + wayland.windowManager.river = { + enable = true; + package = pkgs.unstable.river; + systemd.enable = true; + xwayland.enable = true; + + settings = { + background-color = "0x002b36"; + border-color-focused = "0x93a1a1"; + border-color-unfocused = "0x586e75"; + set-repeat = "50 300"; + + map.normal = lib.mkMerge (lib.flatten [ + { + "Alt+Shift Return" = "spawn foot"; + "Alt P" = "spawn dmenu-wl_run"; + + "Alt Space" = "toggle-fullscreen"; + "Super+Shift C" = "close"; + + # system + "Super L" = "spawn waylock"; + "Super+Shift Q" = "exit"; + } + + (lib.flip lib.mapAttrsToList { K = "previous"; J = "next"; } (k: d: + { + # focus window + "Alt ${k}" = "focus-view ${d}"; + # swap windows + "Alt+Shift ${k}" = "swap ${d}"; + } + )) + + # decrease/increase the main ration + { + "Alt H" = tile-cmd "main-ratio -0.01"; + "Alt L" = tile-cmd "main-ratio +0.01"; + + "Alt Comma" = tile-cmd "main-count +1"; + "Alt Period" = tile-cmd "main-count -1"; + } + + (lib.flip map [ 1 2 3 4 5 6 7 8 9 ] (i: + let wid = i - 1; in + let wtag = pow 2 wid; in + { + "Alt ${toString i}" = "set-focused-tags ${toString wtag}"; + # set-view-tags ${wtag} + # toggle-focused-tags ${wtag} + # toggle-view-tags ${wtag} + } + )) + ]); + }; + + extraConfig = ( + let kb = config.home.keyboard; in '' + riverctl keyboard-layout \ + -model ${kb.model} \ + -variant ${kb.variant} \ + -options ${lib.head kb.options} \ + ${kb.layout} + + riverctl default-layout rivertile + rivertile -view-padding 6 -outer-padding 6 & + '' + ); + }; + }; +} diff --git a/modules/home-manager/programs/terminals/wezterm.nix b/modules/home-manager/programs/terminals/wezterm.nix index c39ad99..fcf7d82 100644 --- a/modules/home-manager/programs/terminals/wezterm.nix +++ b/modules/home-manager/programs/terminals/wezterm.nix @@ -61,7 +61,7 @@ in color_scheme = "myCoolTheme", hide_tab_bar_if_only_one_tab = true, -- https://github.com/wez/wezterm/issues/4483 - enable_wayland = false, + enable_wayland = true, } ''; }; diff --git a/modules/nixos/configs/window-manager/default.nix b/modules/nixos/configs/window-manager/default.nix index ad13197..0cc762b 100644 --- a/modules/nixos/configs/window-manager/default.nix +++ b/modules/nixos/configs/window-manager/default.nix @@ -3,6 +3,7 @@ { imports = [ ./hyprland.nix + ./river.nix ./xmonad.nix ]; diff --git a/modules/nixos/configs/window-manager/river.nix b/modules/nixos/configs/window-manager/river.nix new file mode 100644 index 0000000..c0f932a --- /dev/null +++ b/modules/nixos/configs/window-manager/river.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.local.window-manager.river; +in +{ + options.local.window-manager.river = with lib; { + enable = mkEnableOption "river window manager"; + }; + + config = lib.mkIf cfg.enable { + programs.river = { + enable = true; + package = pkgs.unstable.river; + }; + + programs.gnupg.agent.pinentryFlavor = "gtk2"; + + local.lockscreen.waylock.enable = lib.mkDefault true; + }; +}