refactor(hyprland): migrate to options module

This commit is contained in:
Michael Thomas 2024-06-27 08:02:05 -04:00
parent ee47690a8f
commit e23da5d12c
9 changed files with 334 additions and 299 deletions

View File

@ -92,7 +92,6 @@ in {
fullNixOSModules
++ [
../modules/common.nix
../modules/hyprland.nix
../modules/containers.nix
../modules/applications/libreoffice
../modules/applications/steam

View File

@ -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.

View File

@ -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";
};
};
};
}

View File

@ -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";
};
};
};
};
}

234
nixos/hyprland/home.nix Normal file
View File

@ -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";
}
];
};
};
};
}

18
nixos/wofi/home.nix Normal file
View File

@ -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;
};
};
}

View File

@ -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

View File

@ -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";
}
];
};
};
}

View File

@ -1,5 +0,0 @@
{...}: {
programs.wofi = {
enable = true;
};
}