From 629c9e995cea2d309ca4d6ccf566d19b469fcfdb Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Mon, 22 Apr 2024 23:43:16 +0300 Subject: [PATCH] modules/window-manager: add hyprland --- flake.lock | 6 +- hosts/asus-gl553vd/configuration.nix | 17 +-- hosts/asus-gl553vd/users/jan.nix | 8 +- .../configs/window-manager/default.nix | 1 + .../configs/window-manager/hyprland.nix | 131 ++++++++++++++++++ modules/machine.nix | 2 +- modules/nixos/configs/default.nix | 2 +- .../nixos/configs/window-manager/default.nix | 9 ++ .../nixos/configs/window-manager/hyprland.nix | 19 +++ .../xmonad.nix} | 5 +- users/jan/default.nix | 8 +- 11 files changed, 186 insertions(+), 22 deletions(-) create mode 100644 modules/home-manager/configs/window-manager/hyprland.nix create mode 100644 modules/nixos/configs/window-manager/default.nix create mode 100644 modules/nixos/configs/window-manager/hyprland.nix rename modules/nixos/configs/{window-manager.nix => window-manager/xmonad.nix} (65%) diff --git a/flake.lock b/flake.lock index 914e4b7..fbd3e32 100644 --- a/flake.lock +++ b/flake.lock @@ -492,11 +492,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1711593151, - "narHash": "sha256-/9NCoPI7fqJIN8viONsY9X0fAeq8jc3GslFCO0ky6TQ=", + "lastModified": 1713714268, + "narHash": "sha256-ZJGnom7YthvNxUZLdUzy5VePTwYgDYcnnPpyHT4n9lY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "bb2b73df7bcfbd2dd55ff39b944d70547d53c267", + "rev": "69ee1d82f1fa4c70a3dc9a64111e7eef3b8e4527", "type": "github" }, "original": { diff --git a/hosts/asus-gl553vd/configuration.nix b/hosts/asus-gl553vd/configuration.nix index b539658..7cee4fa 100644 --- a/hosts/asus-gl553vd/configuration.nix +++ b/hosts/asus-gl553vd/configuration.nix @@ -1,4 +1,4 @@ -{ globalData, ... }: +{ ... }: { imports = [ @@ -8,15 +8,12 @@ ]; ################################################################################ - # Programs + # Window manager ################################################################################ - local.programs.browsers.tor-browser = { - enable = true; - container = { - enable = true; - externalInterface = "wg0"; - sshAuthorizedKeys = globalData.publicKeys.users.jan; - }; + + local.window-manager = { + xmonad.enable = false; + hyprland.enable = true; }; ################################################################################ @@ -24,7 +21,7 @@ ################################################################################ # Enable the Docker - virtualisation.docker.enable = true; + # virtualisation.docker.enable = true; # Torrent # services.transmission.enable = true; diff --git a/hosts/asus-gl553vd/users/jan.nix b/hosts/asus-gl553vd/users/jan.nix index 7a9b473..a65313b 100644 --- a/hosts/asus-gl553vd/users/jan.nix +++ b/hosts/asus-gl553vd/users/jan.nix @@ -9,12 +9,18 @@ in home-manager.users.jan = { local.window-manager = { + hyprland.enable = true; + + polybar.enable = false; + xmonad.enable = false; xmonad.projects = import ./xmonad-projects.secret.nix; }; + local.programs.terminals.wezterm.enable = false; + # local.programs.dev-tools.k8s.enable = true; - local.programs.libreoffice.enable = true; + local.programs.libreoffice.enable = false; local.services.lan-mouse.settings = { port = asusData.lan-mouse.port; diff --git a/modules/home-manager/configs/window-manager/default.nix b/modules/home-manager/configs/window-manager/default.nix index 7a6437a..e784004 100644 --- a/modules/home-manager/configs/window-manager/default.nix +++ b/modules/home-manager/configs/window-manager/default.nix @@ -3,6 +3,7 @@ { imports = [ ./xmonad.nix + ./hyprland.nix ./polybar.nix ]; } diff --git a/modules/home-manager/configs/window-manager/hyprland.nix b/modules/home-manager/configs/window-manager/hyprland.nix new file mode 100644 index 0000000..2551548 --- /dev/null +++ b/modules/home-manager/configs/window-manager/hyprland.nix @@ -0,0 +1,131 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.local.window-manager.hyprland; +in +{ + options.local.window-manager.hyprland = with lib; { + enable = mkEnableOption "hyperland window manager"; + }; + + config = lib.mkIf cfg.enable { + home.packages = with pkgs.unstable; [ + foot + wl-clipboard + wlsunset + swaybg + dmenu-wayland + ]; + + wayland.windowManager.hyprland = { + enable = true; + package = pkgs.unstable.hyprland; + systemd.enable = true; + xwayland.enable = true; + + settings = { + # monitors + + monitor = ",preferred,auto,auto"; + + # env + + env = [ + "XCURSOR_SIZE,24" + "HYPRCURSOR_SIZE,24" + ]; + + # look and feel + + general = { + gaps_in = 5; + gaps_out = 20; + + border_size = 2; + + "col.active_border" = "rgba(33ccffee) rgba(00ff99ee) 45deg"; + "col.inactive_border" = "rgba(595959aa)"; + + resize_on_border = false; + + allow_tearing = false; + + layout = "master"; + }; + + decoration = { + rounding = 5; + + active_opacity = 1.0; + inactive_opacity = 1.0; + + drop_shadow = false; + + blur = { + enabled = false; + }; + }; + + animations = { + enabled = false; + + }; + + master = { + orientation = "top"; + new_is_master = false; + }; + + gestures = { + workspace_swipe = false; + }; + + + "$terminal" = "foot"; + "$browser" = "librewolf"; + "$fileManager" = "vifm"; + "$menu" = "dmenu-wl_run"; + + "$mod" = "ALT_L"; + + bind = lib.flatten [ + # programs + + "$mod SHIFT, Return, exec, $terminal" + "$mod SHIFT, S, exec, flameshot gui" + "$mod SHIFT, B, exec, $browser" + "$mod, p, exec, $menu" + + # Move focus + (lib.flip lib.mapAttrsToList { L = "r"; H = "l"; J = "d"; K = "u"; } (k: d: + "$mod, ${k}, movefocus, ${d}" + )) + + (lib.flip map [ 1 2 3 4 5 6 7 8 9 0 ] (i: + let wid = if i == 0 then 10 else i; in + [ + # switch warkspaces with mod + [0-9] + "$mod, ${toString i}, workspace, ${toString wid}" + # move active window to a workspace with mod + shift + [0-9] + "$mod SHIFT, ${toString i}, movetoworkspace, ${toString wid}" + ] + )) + ]; + + bindm = [ + "$mod, mouse:272, movewindow" + "$mod, mouse:273, resizewindow" + + ]; + + input = let kb = config.home.keyboard; in { + kb_model = kb.model; + kb_layout = kb.layout; + kb_variant = kb.variant; + kb_options = lib.head kb.options; + }; + + }; + }; + }; +} diff --git a/modules/machine.nix b/modules/machine.nix index b95e829..68a1053 100644 --- a/modules/machine.nix +++ b/modules/machine.nix @@ -15,7 +15,7 @@ local.fonts.enable = lib.mkDefault true; local.sound.enable = lib.mkDefault true; - local.window-manager.enable = lib.mkDefault true; + local.window-manager.xmonad.enable = lib.mkDefault true; ################################################################################ # Services diff --git a/modules/nixos/configs/default.nix b/modules/nixos/configs/default.nix index fb07fc0..c72e916 100644 --- a/modules/nixos/configs/default.nix +++ b/modules/nixos/configs/default.nix @@ -7,6 +7,6 @@ ./nix.nix ./sound.nix ./system.nix - ./window-manager.nix + ./window-manager ]; } diff --git a/modules/nixos/configs/window-manager/default.nix b/modules/nixos/configs/window-manager/default.nix new file mode 100644 index 0000000..ad13197 --- /dev/null +++ b/modules/nixos/configs/window-manager/default.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + imports = [ + ./hyprland.nix + ./xmonad.nix + ]; + +} diff --git a/modules/nixos/configs/window-manager/hyprland.nix b/modules/nixos/configs/window-manager/hyprland.nix new file mode 100644 index 0000000..53d866c --- /dev/null +++ b/modules/nixos/configs/window-manager/hyprland.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.local.window-manager.hyprland; +in +{ + options.local.window-manager.hyprland = with lib; { + enable = mkEnableOption "hyperland window manager"; + }; + + config = lib.mkIf cfg.enable { + programs.hyprland = { + enable = true; + package = pkgs.unstable.hyprland; + }; + + programs.gnupg.agent.pinentryFlavor = "gtk2"; + }; +} diff --git a/modules/nixos/configs/window-manager.nix b/modules/nixos/configs/window-manager/xmonad.nix similarity index 65% rename from modules/nixos/configs/window-manager.nix rename to modules/nixos/configs/window-manager/xmonad.nix index e13733d..9d7d43c 100644 --- a/modules/nixos/configs/window-manager.nix +++ b/modules/nixos/configs/window-manager/xmonad.nix @@ -1,9 +1,10 @@ { config, pkgs, lib, ... }: +let cfg = config.local.window-manager.xmonad; in { - options.local.window-manager.enable = lib.mkEnableOption "window-manager"; + options.local.window-manager.xmonad.enable = lib.mkEnableOption "window-manager"; - config = lib.mkIf config.local.window-manager.enable { + config = lib.mkIf cfg.enable { services.dbus = { enable = true; packages = [ pkgs.dconf ]; diff --git a/users/jan/default.nix b/users/jan/default.nix index d499657..bc228e4 100644 --- a/users/jan/default.nix +++ b/users/jan/default.nix @@ -52,13 +52,13 @@ }; local.window-manager = { - xmonad.enable = true; - polybar.enable = true; + xmonad.enable = lib.mkDefault true; + polybar.enable = lib.mkDefault true; }; - xdg.enable = true; + xdg.enable = lib.mkDefault true; - local.shell.enable = true; + local.shell.enable = lib.mkDefault true; ################################################################################