From e23da5d12cbcd50f145b972d2e16f4b0e7b53986 Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Thu, 27 Jun 2024 08:02:05 -0400 Subject: [PATCH] refactor(hyprland): migrate to options module --- flakes/nixos.nix | 1 - machines/terra/configuration.nix | 1 + modules/hyprland.nix | 69 --------- nixos/hyprland/default.nix | 81 +++++++++++ nixos/hyprland/home.nix | 234 +++++++++++++++++++++++++++++++ nixos/wofi/home.nix | 18 +++ user/environments/nixos/home.nix | 1 - user/modules/hyprland.nix | 223 ----------------------------- user/modules/wofi.nix | 5 - 9 files changed, 334 insertions(+), 299 deletions(-) delete mode 100644 modules/hyprland.nix create mode 100644 nixos/hyprland/default.nix create mode 100644 nixos/hyprland/home.nix create mode 100644 nixos/wofi/home.nix delete mode 100644 user/modules/hyprland.nix delete mode 100644 user/modules/wofi.nix diff --git a/flakes/nixos.nix b/flakes/nixos.nix index bac2a3f..758a385 100644 --- a/flakes/nixos.nix +++ b/flakes/nixos.nix @@ -92,7 +92,6 @@ in { fullNixOSModules ++ [ ../modules/common.nix - ../modules/hyprland.nix ../modules/containers.nix ../modules/applications/libreoffice ../modules/applications/steam diff --git a/machines/terra/configuration.nix b/machines/terra/configuration.nix index 721c225..4235362 100644 --- a/machines/terra/configuration.nix +++ b/machines/terra/configuration.nix @@ -47,6 +47,7 @@ programs.zsh.enable = true; environment.variables.EDITOR = "nvim"; + my.hyprland.enable = true; my.libreoffice.enable = true; # Define a user account. Don't forget to set a password with ‘passwd’. diff --git a/modules/hyprland.nix b/modules/hyprland.nix deleted file mode 100644 index 2b4275c..0000000 --- a/modules/hyprland.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ - pkgs, - inputs, - ... -}: let - pkgs-hyprland = inputs.hyprland.inputs.nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system}; -in { - programs.hyprland = { - enable = true; - package = inputs.hyprland.packages.${pkgs.system}.hyprland; - }; - - hardware.opengl = { - package = pkgs-hyprland.mesa.drivers; - driSupport32Bit = true; - package32 = pkgs-hyprland.pkgsi686Linux.mesa.drivers; - }; - - services.gnome.gnome-keyring.enable = true; - security.pam.services.greetd.enableGnomeKeyring = true; - - environment.systemPackages = with pkgs; [ - # Theme - adw-gtk3 - - # Applications - gnome.nautilus - gnome.sushi - gnome.eog - gnome.totem - gnome.cheese - gnome.file-roller - gnome.gnome-weather - gnome.gnome-contacts - gnome.gnome-calendar - gnome.gnome-screenshot - gnome.gnome-dictionary - gnome.gnome-font-viewer - gnome.gnome-system-monitor - monophony # music player - - # Nvim clipboard - wl-clipboard - ]; - - # Required for Nautilus to work outside GNOME - services.gvfs.enable = true; - - # Use CAPSLOCK as Hyper key - services.keyd = { - enable = true; - keyboards.default = { - ids = ["*"]; - settings.main = { - capslock = "overload(meta, esc)"; - }; - }; - }; - - services.greetd = { - enable = true; - settings = { - default_session = { - command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland"; - user = "greeter"; - }; - }; - }; -} diff --git a/nixos/hyprland/default.nix b/nixos/hyprland/default.nix new file mode 100644 index 0000000..268c4c0 --- /dev/null +++ b/nixos/hyprland/default.nix @@ -0,0 +1,81 @@ +{ + pkgs, + inputs, + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + pkgs-hyprland = inputs.hyprland.inputs.nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system}; + cfg = config.my.hyprland; +in { + options.my.hyprland = { + enable = mkEnableOption "hyprland"; + }; + + config = mkIf cfg.enable { + hm.my.hyprland.enable = true; + + programs.hyprland = { + enable = true; + package = inputs.hyprland.packages.${pkgs.system}.hyprland; + }; + + hardware.opengl = { + package = pkgs-hyprland.mesa.drivers; + driSupport32Bit = true; + package32 = pkgs-hyprland.pkgsi686Linux.mesa.drivers; + }; + + services.gnome.gnome-keyring.enable = true; + security.pam.services.greetd.enableGnomeKeyring = true; + + environment.systemPackages = with pkgs; [ + # Theme + adw-gtk3 + + # Applications + gnome.nautilus + gnome.sushi + gnome.eog + gnome.totem + gnome.cheese + gnome.file-roller + gnome.gnome-weather + gnome.gnome-contacts + gnome.gnome-calendar + gnome.gnome-screenshot + gnome.gnome-dictionary + gnome.gnome-font-viewer + gnome.gnome-system-monitor + monophony # music player + + # Nvim clipboard + wl-clipboard + ]; + + # Required for Nautilus to work outside GNOME + services.gvfs.enable = true; + + # Use CAPSLOCK as Hyper key + services.keyd = { + enable = true; + keyboards.default = { + ids = ["*"]; + settings.main = { + capslock = "overload(meta, esc)"; + }; + }; + }; + + services.greetd = { + enable = true; + settings = { + default_session = { + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland"; + user = "greeter"; + }; + }; + }; + }; +} diff --git a/nixos/hyprland/home.nix b/nixos/hyprland/home.nix new file mode 100644 index 0000000..d29285e --- /dev/null +++ b/nixos/hyprland/home.nix @@ -0,0 +1,234 @@ +{ + pkgs, + inputs, + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.hyprland; +in { + imports = [ + inputs.hyprland.homeManagerModules.default + ]; + + options.my.hyprland = { + enable = mkEnableOption "hyprland"; + }; + + config = mkIf cfg.enable { + my.wofi.enable = true; + + home.packages = with pkgs; [ + pavucontrol + swaybg + ]; + + wayland.windowManager.hyprland = { + enable = true; + package = inputs.hyprland.packages.${pkgs.system}.hyprland; + settings = let + # No gaps or border when only one window + no_gaps_when_only = 1; + in { + "$mod" = "SUPER"; + general = { + gaps_in = 5; + gaps_out = 10; + }; + input = { + follow_mouse = 2; + }; + dwindle = { + inherit no_gaps_when_only; + }; + master = { + inherit no_gaps_when_only; + }; + exec-once = [ + "hyprctl setcursor Adwaita 24" + "swaybg -i /home/michael/Photos/wallpaper.jpg" + "hypridle" + ]; + bind = + [ + # Program launcher + "$mod, SPACE, exec, wofi --show drun" + # Program shortcuts + "$mod, F, exec, firefox" + "$mod, Q, killactive" + "$mod, T, exec, foot" + ", Print, exec, grimblast copy area" + # Windows + "$mod, H, movefocus, l" + "$mod, J, movefocus, d" + "$mod, K, movefocus, u" + "$mod, L, movefocus, r" + # Moving windows + "$mod SHIFT, H, movewindow, l" + "$mod SHIFT, J, movewindow, d" + "$mod SHIFT, K, movewindow, u" + "$mod SHIFT, L, movewindow, r" + ] + ++ ( + # workspaces + # binds $mod + [shift +] {1..10} to [move to] workspace {1..10} + builtins.concatLists (builtins.genList ( + x: let + ws = let + c = (x + 1) / 10; + in + builtins.toString (x + 1 - (c * 10)); + in [ + "$mod, ${ws}, workspace, ${toString (x + 1)}" + "$mod SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}" + ] + ) + 10) + ); + }; + extraConfig = '' + # will switch to a submap called resize + bind=$mod,R,submap,resize + + # media controls + bindel=, XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ + bindel=, XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- + bindl=, XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle + + # will start a submap called "resize" + submap=resize + + # sets repeatable binds for resizing the active window + binde=,h,resizeactive,-10 0 + binde=,j,resizeactive,0 10 + binde=,k,resizeactive,0 -10 + binde=,l,resizeactive,10 0 + + # use reset to go back to the global submap + bind=,escape,submap,reset + + # will reset the submap, meaning end the current one and return to the global one + submap=reset + ''; + }; + + gtk = { + enable = true; + font.name = "Inter 11"; + theme = { + name = "adw-gtk3-dark"; + package = pkgs.adw-gtk3; + }; + iconTheme = { + name = "Papirus"; + package = pkgs.papirus-icon-theme; + }; + }; + + home.pointerCursor = { + gtk.enable = true; + name = "Adwaita"; + package = pkgs.gnome.adwaita-icon-theme; + size = 24; + }; + + programs.hyprlock = { + enable = true; + settings = { + general = { + no_fade_in = false; + grace = 0; + disable_loading_bar = true; + }; + background = { + monitor = ""; + path = "~/Photos/wallpaper.jpg"; + blur_passes = 3; + contrast = 0.8916; + brightness = 0.8172; + vibrancy = 0.1696; + vibrancy_darkness = 0.0; + }; + input-field = { + monitor = ""; + size = "250, 60"; + outline_thickness = 2; + dots_size = 0.2; # Scale of input-field height, 0.2 - 0.8 + dots_spacing = 0.2; # Scale of dots' absolute size, 0.0 - 1.0 + dots_center = true; + outer_color = "rgba(0, 0, 0, 0)"; + inner_color = "rgba(0, 0, 0, 0.5)"; + font_color = "rgb(200, 200, 200)"; + fade_on_empty = false; + font_family = "Inter"; + placeholder_text = "Enter Password"; + hide_input = false; + position = "0, 375"; + halign = "center"; + valign = "bottom"; + }; + label = [ + # Time + { + monitor = ""; + text = "cmd[update:1000] echo \"$(date +\"%-I:%M %P\")\""; + color = "rgba(255, 255, 255, 0.6)"; + font_size = 120; + font_family = "Inter ExtraBold"; + position = "0, -300"; + halign = "center"; + valign = "top"; + } + # User + { + monitor = ""; + text = config.my.name; + color = "rgba(255, 255, 255, 0.6)"; + font_size = 24; + font_family = "Inter Semibold"; + position = "0, 450"; + halign = "center"; + valign = "bottom"; + } + ]; + }; + }; + + services.hypridle = { + enable = true; + settings = { + general = { + lock_cmd = "pidof hyprlock || hyprlock"; + before_sleep_cmd = "loginctl lock-session"; + after_sleep_cmd = "hyprctl dispatch dpms on"; + }; + + listener = [ + # Dim screen + { + timeout = 150; # 2.5 min + on-timeout = "brightnessctl -s set 10"; # set monitor backlight to minimum, avoid 0 on OLED monitor. + on-resume = "brightnessctl -r"; # monitor backlight restore. + } + # Lock + { + timeout = 300; # 5 min + on-timeout = "loginctl lock-session"; + } + # Turn off screen + { + timeout = 330; # 5.5 min + on-timeout = "hyprctl dispatch dpms off"; + on-resume = "hyprctl dispatch dpms on"; + } + # Suspend + { + timeout = 1800; # 30 min + on-timeout = "systemctl suspend"; + } + ]; + }; + }; + }; +} diff --git a/nixos/wofi/home.nix b/nixos/wofi/home.nix new file mode 100644 index 0000000..17f0709 --- /dev/null +++ b/nixos/wofi/home.nix @@ -0,0 +1,18 @@ +{ + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.wofi; +in { + options.my.wofi = { + enable = mkEnableOption "wofi"; + }; + + config = mkIf cfg.enable { + programs.wofi = { + enable = true; + }; + }; +} diff --git a/user/environments/nixos/home.nix b/user/environments/nixos/home.nix index c41636a..4ef8f66 100644 --- a/user/environments/nixos/home.nix +++ b/user/environments/nixos/home.nix @@ -7,7 +7,6 @@ ../../modules/foot.nix ../../modules/git.nix ../../modules/git_nixos.nix - ../../modules/hyprland.nix ../../modules/nvim.nix ../../modules/vscode.nix ../../modules/zellij diff --git a/user/modules/hyprland.nix b/user/modules/hyprland.nix deleted file mode 100644 index d1069b5..0000000 --- a/user/modules/hyprland.nix +++ /dev/null @@ -1,223 +0,0 @@ -{ - pkgs, - inputs, - ... -}: { - imports = [ - inputs.hyprland.homeManagerModules.default - ./wofi.nix - ]; - - home.packages = with pkgs; [ - pavucontrol - swaybg - ]; - - wayland.windowManager.hyprland = { - enable = true; - package = inputs.hyprland.packages.${pkgs.system}.hyprland; - settings = let - # No gaps or border when only one window - no_gaps_when_only = 1; - in { - "$mod" = "SUPER"; - general = { - gaps_in = 5; - gaps_out = 10; - }; - input = { - follow_mouse = 2; - }; - dwindle = { - inherit no_gaps_when_only; - }; - master = { - inherit no_gaps_when_only; - }; - exec-once = [ - "hyprctl setcursor Adwaita 24" - "ags" - "swaybg -i /home/michael/Photos/wallpaper.jpg" - "hypridle" - ]; - bind = - [ - # Program launcher - "$mod, SPACE, exec, wofi --show drun" - # Program shortcuts - "$mod, F, exec, firefox" - "$mod, Q, killactive" - "$mod, T, exec, foot" - ", Print, exec, grimblast copy area" - # Windows - "$mod, H, movefocus, l" - "$mod, J, movefocus, d" - "$mod, K, movefocus, u" - "$mod, L, movefocus, r" - # Moving windows - "$mod SHIFT, H, movewindow, l" - "$mod SHIFT, J, movewindow, d" - "$mod SHIFT, K, movewindow, u" - "$mod SHIFT, L, movewindow, r" - ] - ++ ( - # workspaces - # binds $mod + [shift +] {1..10} to [move to] workspace {1..10} - builtins.concatLists (builtins.genList ( - x: let - ws = let - c = (x + 1) / 10; - in - builtins.toString (x + 1 - (c * 10)); - in [ - "$mod, ${ws}, workspace, ${toString (x + 1)}" - "$mod SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}" - ] - ) - 10) - ); - }; - extraConfig = '' - # will switch to a submap called resize - bind=$mod,R,submap,resize - - # media controls - bindel=, XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ - bindel=, XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- - bindl=, XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle - - # will start a submap called "resize" - submap=resize - - # sets repeatable binds for resizing the active window - binde=,h,resizeactive,-10 0 - binde=,j,resizeactive,0 10 - binde=,k,resizeactive,0 -10 - binde=,l,resizeactive,10 0 - - # use reset to go back to the global submap - bind=,escape,submap,reset - - # will reset the submap, meaning end the current one and return to the global one - submap=reset - ''; - }; - - gtk = { - enable = true; - font.name = "Inter 11"; - theme = { - name = "adw-gtk3-dark"; - package = pkgs.adw-gtk3; - }; - iconTheme = { - name = "Papirus"; - package = pkgs.papirus-icon-theme; - }; - }; - - home.pointerCursor = { - gtk.enable = true; - name = "Adwaita"; - package = pkgs.gnome.adwaita-icon-theme; - size = 24; - }; - - programs.hyprlock = { - enable = true; - settings = { - general = { - no_fade_in = false; - grace = 0; - disable_loading_bar = true; - }; - background = { - monitor = ""; - path = "~/Photos/wallpaper.jpg"; - blur_passes = 3; - contrast = 0.8916; - brightness = 0.8172; - vibrancy = 0.1696; - vibrancy_darkness = 0.0; - }; - input-field = { - monitor = ""; - size = "250, 60"; - outline_thickness = 2; - dots_size = 0.2; # Scale of input-field height, 0.2 - 0.8 - dots_spacing = 0.2; # Scale of dots' absolute size, 0.0 - 1.0 - dots_center = true; - outer_color = "rgba(0, 0, 0, 0)"; - inner_color = "rgba(0, 0, 0, 0.5)"; - font_color = "rgb(200, 200, 200)"; - fade_on_empty = false; - font_family = "Inter"; - placeholder_text = "Enter Password"; - hide_input = false; - position = "0, 375"; - halign = "center"; - valign = "bottom"; - }; - label = [ - # Time - { - monitor = ""; - text = "cmd[update:1000] echo \"$(date +\"%-I:%M %P\")\""; - color = "rgba(255, 255, 255, 0.6)"; - font_size = 120; - font_family = "Inter ExtraBold"; - position = "0, -300"; - halign = "center"; - valign = "top"; - } - # User - { - monitor = ""; - text = "Michael Thomas"; - color = "rgba(255, 255, 255, 0.6)"; - font_size = 24; - font_family = "Inter Semibold"; - position = "0, 450"; - halign = "center"; - valign = "bottom"; - } - ]; - }; - }; - - services.hypridle = { - enable = true; - settings = { - general = { - lock_cmd = "pidof hyprlock || hyprlock"; - before_sleep_cmd = "loginctl lock-session"; - after_sleep_cmd = "hyprctl dispatch dpms on"; - }; - - listener = [ - # Dim screen - { - timeout = 150; # 2.5 min - on-timeout = "brightnessctl -s set 10"; # set monitor backlight to minimum, avoid 0 on OLED monitor. - on-resume = "brightnessctl -r"; # monitor backlight restore. - } - # Lock - { - timeout = 300; # 5 min - on-timeout = "loginctl lock-session"; - } - # Turn off screen - { - timeout = 330; # 5.5 min - on-timeout = "hyprctl dispatch dpms off"; - on-resume = "hyprctl dispatch dpms on"; - } - # Suspend - { - timeout = 1800; # 30 min - on-timeout = "systemctl suspend"; - } - ]; - }; - }; -} diff --git a/user/modules/wofi.nix b/user/modules/wofi.nix deleted file mode 100644 index e96db9a..0000000 --- a/user/modules/wofi.nix +++ /dev/null @@ -1,5 +0,0 @@ -{...}: { - programs.wofi = { - enable = true; - }; -}