diff --git a/lib/home.nix b/lib/home.nix index 7b8e74a..375c92a 100644 --- a/lib/home.nix +++ b/lib/home.nix @@ -26,14 +26,12 @@ (import ./modules/dev.nix {inherit user;}) (import ./modules/personal.nix {inherit user;}) (import ./modules/gamer.nix {inherit user;}) - (import ./modules/wayland.nix {inherit user;}) + (import ./programs/hyprland.nix {inherit user;}) (import ../hardware/${name}.nix {inherit user;}) ./scripts.nix (import ../global/system.nix user) ]; - windowManager.hyprland = true; - programs.menu.enable = true; roles.work.enable = work; roles.personal.enable = !work; diff --git a/lib/modules/wayland.nix b/lib/modules/wayland.nix index 5696502..07ec219 100644 --- a/lib/modules/wayland.nix +++ b/lib/modules/wayland.nix @@ -5,307 +5,12 @@ ... }: with lib; let - cfg = config.windowManager; + opt = config.windowManager; in { - options.windowManager = { - hyprland = mkEnableOption "hyprland"; - sway = mkEnableOption "sway"; + options.windowManager = mkOption { + default = null; + type = lib.types.oneOf ["hyprland" "sway"]; }; - config = mkIf (cfg.sway || cfg.hyprland) { - services.greetd = { - enable = true; - settings = rec { - hypr_session = { - command = "Hyprland"; - user = user; - }; - sway_session = { - command = "sway"; - user = user; - }; - default_session = - if cfg.sway - then sway_session - else hypr_session; - }; - }; - - home-manager.users.${user}.imports = [ - { - xdg.portal = { - enable = true; - config.common.default = ["hyprland"]; - extraPortals = if cfg.hyprland then [ pkgs.xdg-desktop-portal-hyprland ] else if cfg.sway then [ pkgs.xdg-desktop-portal-sway ] else []; - }; - - wayland.windowManager.hyprland = mkIf cfg.hyprland { - enable = true; - systemd.enable = true; - settings = { - input = { - touchpad = { - natural_scroll = true; - scroll_factor = 0.5; - }; - }; - gestures = { - workspace_swipe = true; - workspace_swipe_numbered = true; - }; - decoration = { - rounding = 5; - drop_shadow = false; - }; - bezier = [ - "overshot, 0.05, 0.9, 0.1, 1.1" - "linear, 0.0, 0.0, 1.0, 1.0" - ]; - animations = { - enabled = true; - animation = [ - "windows, 1, 1, default, popin" - "border, 1, 1, default" - "fade, 1, 1, default" - "workspaces, 1, 3, overshot" - "borderangle,1, 50, linear, loop" - ]; - }; - bind = [ - "SUPER, h, movefocus,l" - "SUPER, l, movefocus,r" - "SUPER, j, layoutmsg,cyclenext" - "SUPER, k, layoutmsg,cycleprev" - "SUPER, space, layoutmsg,swapwithmaster master" - "SUPER, F, fullscreen," - "SUPER, V, togglefloating," - "SUPER, W, layoutmsg, orientationprev" - "SUPER_SHIFT, W, layoutmsg, orientationnext" - "SUPER_SHIFT, V, togglegroup," - "SUPER_SHIFT, h, changegroupactive,b" - "SUPER_SHIFT, h, moveintogroup,l" - "SUPER_SHIFT, l, moveintogroup,r" - "SUPER_SHIFT, l, changegroupactive,f" - "SUPER, Y, togglespecialworkspace" - "SUPER_SHIFT, Y, movetoworkspace, special" - "SUPER_SHIFT, X, killactive" - "SUPER, slash, focuswindow, brave-browser" - "SUPER, n, focuswindow, Logseq" - "SUPER, R, submap, resize" - "SUPER,1,workspace,1" - "SUPER,2,workspace,2" - "SUPER,3,workspace,3" - "SUPER,4,workspace,4" - "SUPER,5,workspace,5" - "SUPER,6,workspace,6" - "SUPER,7,workspace,7" - "SUPER,8,workspace,8" - "SUPER,9,workspace,9" - "SUPER,0,workspace,10" - "SUPER,left,workspace,r-1" - "SUPER,right,workspace,r+1" - "SUPER_SHIFT,1,movetoworkspace,1" - "SUPER_SHIFT,2,movetoworkspace,2" - "SUPER_SHIFT,3,movetoworkspace,3" - "SUPER_SHIFT,4,movetoworkspace,4" - "SUPER_SHIFT,5,movetoworkspace,5" - "SUPER_SHIFT,6,movetoworkspace,6" - "SUPER_SHIFT,7,movetoworkspace,7" - "SUPER_SHIFT,8,movetoworkspace,8" - "SUPER_SHIFT,9,movetoworkspace,9" - "SUPER_SHIFT,0,movetoworkspace,10" - ]; - bindm = [ - "SUPER, mouse:272, movewindow" - "SUPER, mouse:273, resizewindow" - ]; - env = [ - "GDK_BACKEND,wayland,x11" - "QT_QPA_PLATFORM,wayland;xcb" - "SDL_VIDEODRIVER,wayland" - "CLUTTER_BACKEND,wayland" - "XDG_CURRENT_DESKTOP,Hyprland" - "XDG_SESSION_TYPE,wayland" - "XDG_SESSION_DESKTOP,Hyprland" - "QT_AUTO_SCREEN_SCALE_FACTOR,1" - "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" - "NIXOS_OZONE_WL,1" - "WLR_NO_HARDWARE_CURSORS,1" - ]; - windowrule = [ - "float, title:wlogout" - "idleinhibit always, vrmonitor" - "idleinhibit focus, steam_app" - ]; - workspace = [ - "11, default:true" - ]; - general = { - gaps_out = 10; - resize_on_border = true; - layout = "master"; - # "col.active_border" = "rgb(FFFF00) rgb(00FFFF) rgb(FF00FF)"; - border_size = lib.mkDefault 5; - }; - master = { - mfact = 0.7; - new_on_top = true; - }; - misc = { - vrr = 2; - focus_on_activate = true; - }; - }; - # https://wiki.hyprland.org/Configuring/Variables/ - extraConfig = '' - submap = resize - binde = ,right,resizeactive,10 0 - binde = ,left,resizeactive,-10 0 - binde = ,up,resizeactive,0 -10 - binde = ,down,resizeactive,0 10 - binde = ,k,resizeactive,0 -10 - binde = ,j,resizeactive,0 10 - binde = ,l,splitratio,0.05 - binde = ,h,splitratio,-0.05 - binde = SHIFT,l,splitratio,0.3 - binde = SHIFT,h,splitratio,-0.3 - - bind = , escape, submap,reset - bind = , enter, submap,reset - bind = SUPER, R, submap,reset - bind = CONTROL, C, submap,reset - submap = reset - ''; - }; - - wayland.windowManager.sway = mkIf cfg.sway { - enable = true; - }; - - programs.swaylock = { - enable = true; - package = pkgs.swaylock-effects; - settings = { - clock = true; - screenshots = true; - effect-scale = 0.5; - effect-blur = "10x10"; - grace = 5; - }; - }; - - services.swayidle = { - enable = true; - systemdTarget = "graphical-session.target"; - events = [ - { - event = "before-sleep"; - command = "${pkgs.swaylock-effects}/bin/swaylock"; - } - { - event = "lock"; - command = "${pkgs.swaylock-effects}/bin/swaylock"; - } - ]; - timeouts = [ - { - timeout = 300; - command = "${pkgs.swaylock-effects}/bin/swaylock -f"; - } - { - timeout = 600; - command = "systemctl suspend"; - } - ]; - }; - - services.mako = { - enable = true; - }; - - programs.waybar = { - enable = true; - settings = { - mainBar = { - layer = "top"; - position = "top"; - height = 36; - modules-left = ["hyprland/workspaces" "hyprland/window"]; - modules-right = ["mpris" "pulseaudio" "clock" "tray" "battery"]; - clock = { - format = "πŸ“… {:%a %b-%d %I:%M %p}"; - }; - pulseaudio = { - format-muted = "πŸ”‡ {volume}"; - format = "{icon} {volume}"; - format-icons.default = ["πŸ”ˆ" "πŸ”‰" "πŸ”Š"]; - on-click = "${pkgs.pavucontrol}/bin/pavucontrol"; - }; - mpris = { - format = "{player_icon} {artist} - {title}"; - format-paused = "{status_icon} {player_icon} {artist} - {title}"; - player-icons = { - default = "▢️"; - mpd = "🎡"; - kdeconnect = "☎️"; - }; - status-icons = { - paused = "⏸️"; - }; - }; - battery = { - format = "{icon} {capacity}%"; - format-icons = ["🀏" "πŸͺ«" "πŸ”‹" "πŸ”‹"]; - format-charging = "πŸ”Œ {capacity}%"; - states = { - warning = 30; - critical = 15; - }; - }; - }; - }; - systemd = { - enable = true; - target = "graphical-session.target"; - }; - style = '' - * { - min-height: 0; - } - - window#waybar { - font-size: small; - background: rgba(0,0,0,0.8); - } - - #workspaces button { - border-radius: 1rem; - padding: 0px .5rem; - margin: 0px .5rem 0px 0px; - } - - #workspaces button.active { - background: rgba(255,255,255,0.8); - padding: 0px 1rem; - color: black; - } - - #workspaces button.inactive:hover { - background: rgba(255,255,255,0.4); - color: black; - } - - .modules-right widget label { - padding: 0 1rem; - margin: 0 .5rem; - } - - #tray { - min-width: 5rem; - } - ''; - }; - } - ]; - }; + config = if opt == "hyprland" then (import ../programs/hyprland.nix {inherit user;} {inherit lib pkgs;}) else {}; } diff --git a/lib/programs/hyprland.nix b/lib/programs/hyprland.nix new file mode 100644 index 0000000..badd334 --- /dev/null +++ b/lib/programs/hyprland.nix @@ -0,0 +1,176 @@ +{user}: { + lib, + pkgs, + ... +}: { + services.greetd = { + enable = true; + settings = rec { + hypr_session = { + command = "Hyprland"; + user = user; + }; + default_session = hypr_session; + }; + }; + + home-manager.users.${user}.imports = [ + ( import ./swaylock.nix ) + ( import ./swayidle.nix ) + { + xdg.portal = { + enable = true; + configPackages = [ pkgs.hyprland ]; + extraPortals = [ pkgs.xdg-desktop-portal-hyprland pkgs.xdg-desktop-portal-gtk ]; + }; + + wayland.windowManager.hyprland = { + enable = true; + systemd.enable = true; + settings = { + input = { + touchpad = { + natural_scroll = true; + scroll_factor = 0.5; + }; + }; + gestures = { + workspace_swipe = true; + workspace_swipe_numbered = true; + }; + decoration = { + rounding = 5; + drop_shadow = false; + }; + bezier = [ + "overshot, 0.05, 0.9, 0.1, 1.1" + "linear, 0.0, 0.0, 1.0, 1.0" + ]; + animations = { + enabled = true; + animation = [ + "windows, 1, 1, default, popin" + "border, 1, 1, default" + "fade, 1, 1, default" + "workspaces, 1, 3, overshot" + "borderangle,1, 50, linear, loop" + ]; + }; + bind = [ + "SUPER, h, movefocus,l" + "SUPER, l, movefocus,r" + "SUPER, j, layoutmsg,cyclenext" + "SUPER, k, layoutmsg,cycleprev" + "SUPER, space, layoutmsg,swapwithmaster master" + "SUPER, F, fullscreen," + "SUPER, V, togglefloating," + "SUPER, W, layoutmsg, orientationprev" + "SUPER_SHIFT, W, layoutmsg, orientationnext" + "SUPER_SHIFT, V, togglegroup," + "SUPER_SHIFT, h, changegroupactive,b" + "SUPER_SHIFT, h, moveintogroup,l" + "SUPER_SHIFT, l, moveintogroup,r" + "SUPER_SHIFT, l, changegroupactive,f" + "SUPER, Y, togglespecialworkspace" + "SUPER_SHIFT, Y, movetoworkspace, special" + "SUPER_SHIFT, X, killactive" + "SUPER, slash, focuswindow, brave-browser" + "SUPER, n, focuswindow, Logseq" + "SUPER, R, submap, resize" + "SUPER,1,workspace,1" + "SUPER,2,workspace,2" + "SUPER,3,workspace,3" + "SUPER,4,workspace,4" + "SUPER,5,workspace,5" + "SUPER,6,workspace,6" + "SUPER,7,workspace,7" + "SUPER,8,workspace,8" + "SUPER,9,workspace,9" + "SUPER,0,workspace,10" + "SUPER,left,workspace,r-1" + "SUPER,right,workspace,r+1" + "SUPER_SHIFT,1,movetoworkspace,1" + "SUPER_SHIFT,2,movetoworkspace,2" + "SUPER_SHIFT,3,movetoworkspace,3" + "SUPER_SHIFT,4,movetoworkspace,4" + "SUPER_SHIFT,5,movetoworkspace,5" + "SUPER_SHIFT,6,movetoworkspace,6" + "SUPER_SHIFT,7,movetoworkspace,7" + "SUPER_SHIFT,8,movetoworkspace,8" + "SUPER_SHIFT,9,movetoworkspace,9" + "SUPER_SHIFT,0,movetoworkspace,10" + ]; + bindm = [ + "SUPER, mouse:272, movewindow" + "SUPER, mouse:273, resizewindow" + ]; + env = [ + "GDK_BACKEND,wayland,x11" + "QT_QPA_PLATFORM,wayland;xcb" + "SDL_VIDEODRIVER,wayland" + "CLUTTER_BACKEND,wayland" + "XDG_CURRENT_DESKTOP,Hyprland" + "XDG_SESSION_TYPE,wayland" + "XDG_SESSION_DESKTOP,Hyprland" + "QT_AUTO_SCREEN_SCALE_FACTOR,1" + "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" + "NIXOS_OZONE_WL,1" + "WLR_NO_HARDWARE_CURSORS,1" + ]; + windowrule = [ + "float, title:wlogout" + "idleinhibit always, vrmonitor" + "idleinhibit focus, steam_app" + ]; + workspace = [ + "11, default:true" + ]; + general = { + gaps_out = 10; + resize_on_border = true; + layout = "master"; + # "col.active_border" = "rgb(FFFF00) rgb(00FFFF) rgb(FF00FF)"; + border_size = lib.mkDefault 5; + }; + master = { + mfact = 0.7; + new_on_top = true; + }; + misc = { + vrr = 2; + focus_on_activate = true; + }; + }; + # https://wiki.hyprland.org/Configuring/Variables/ + extraConfig = '' + submap = resize + binde = ,right,resizeactive,10 0 + binde = ,left,resizeactive,-10 0 + binde = ,up,resizeactive,0 -10 + binde = ,down,resizeactive,0 10 + binde = ,k,resizeactive,0 -10 + binde = ,j,resizeactive,0 10 + binde = ,l,splitratio,0.05 + binde = ,h,splitratio,-0.05 + binde = SHIFT,l,splitratio,0.3 + binde = SHIFT,h,splitratio,-0.3 + + bind = , escape, submap,reset + bind = , enter, submap,reset + bind = SUPER, R, submap,reset + bind = CONTROL, C, submap,reset + submap = reset + ''; + }; + + services.mako = { + enable = true; + }; + + programs.waybar.settings.mainBar.modules-left = + ["hyprland/workspaces" "hyprland/window"]; + + + } + ]; + } diff --git a/lib/programs/sway.nix b/lib/programs/sway.nix new file mode 100644 index 0000000..2ae608e --- /dev/null +++ b/lib/programs/sway.nix @@ -0,0 +1,106 @@ +{user}: { + lib, + pkgs, + config, + ... +}: { + services.greetd = { + enable = true; + settings = rec { + sway_session = { + command = "sway"; + user = user; + }; + default_session = sway_session; + }; + }; + + home-manager.users.${user}.imports = [ + ( import ./swaylock.nix ) + { + xdg.portal = { + enable = true; + configPackages = [ pkgs.sway ]; + extraPortals = [ pkgs.xdg-desktop-portal-sway pkgs.xdg-desktop-portal-gtk ]; + }; + + wayland.windowManager.sway = { + enable = true; + }; + + services.swayidle = { + enable = true; + systemdTarget = "graphical-session.target"; + events = [ + { + event = "before-sleep"; + command = "${pkgs.swaylock-effects}/bin/swaylock"; + } + { + event = "lock"; + command = "${pkgs.swaylock-effects}/bin/swaylock"; + } + ]; + timeouts = [ + { + timeout = 300; + command = "${pkgs.swaylock-effects}/bin/swaylock -f"; + } + { + timeout = 600; + command = "systemctl suspend"; + } + ]; + }; + + services.mako.enable = true; + + programs.waybar = { + enable = true; + settings = { + mainBar = { + layer = "top"; + position = "top"; + height = 36; + modules-left = ["sway/workspaces" "sway/window"]; + modules-right = ["mpris" "pulseaudio" "clock" "tray" "battery"]; + clock = { + format = "πŸ“… {:%a %b-%d %I:%M %p}"; + }; + pulseaudio = { + format-muted = "πŸ”‡ {volume}"; + format = "{icon} {volume}"; + format-icons.default = ["πŸ”ˆ" "πŸ”‰" "πŸ”Š"]; + on-click = "${pkgs.pavucontrol}/bin/pavucontrol"; + }; + mpris = { + format = "{player_icon} {artist} - {title}"; + format-paused = "{status_icon} {player_icon} {artist} - {title}"; + player-icons = { + default = "▢️"; + mpd = "🎡"; + kdeconnect = "☎️"; + }; + status-icons = { + paused = "⏸️"; + }; + }; + battery = { + format = "{icon} {capacity}%"; + format-icons = ["🀏" "πŸͺ«" "πŸ”‹" "πŸ”‹"]; + format-charging = "πŸ”Œ {capacity}%"; + states = { + warning = 30; + critical = 15; + }; + }; + }; + }; + systemd = { + enable = true; + target = "graphical-session.target"; + }; + }; + } + ]; +} diff --git a/lib/programs/swayidle.nix b/lib/programs/swayidle.nix new file mode 100644 index 0000000..f5851f1 --- /dev/null +++ b/lib/programs/swayidle.nix @@ -0,0 +1,28 @@ +{pkgs,...}: { + + services.swayidle = { + enable = true; + systemdTarget = "graphical-session.target"; + events = [ + { + event = "before-sleep"; + command = "${pkgs.swaylock-effects}/bin/swaylock"; + } + { + event = "lock"; + command = "${pkgs.swaylock-effects}/bin/swaylock"; + } + ]; + timeouts = [ + { + timeout = 300; + command = "${pkgs.swaylock-effects}/bin/swaylock -f"; + } + { + timeout = 600; + command = "systemctl suspend"; + } + ]; + }; + +} diff --git a/lib/programs/swaylock.nix b/lib/programs/swaylock.nix new file mode 100644 index 0000000..ed5254a --- /dev/null +++ b/lib/programs/swaylock.nix @@ -0,0 +1,14 @@ +{pkgs,...}: { + + programs.swaylock = { + enable = true; + package = pkgs.swaylock-effects; + settings = { + clock = true; + screenshots = true; + effect-scale = 0.5; + effect-blur = "10x10"; + grace = 5; + }; + }; +} diff --git a/lib/programs/waybar.nix b/lib/programs/waybar.nix new file mode 100644 index 0000000..c51344a --- /dev/null +++ b/lib/programs/waybar.nix @@ -0,0 +1,50 @@ +{pkgs,...}: { + programs.waybar = { + enable = true; + settings = { + mainBar = { + layer = "top"; + position = "top"; + height = 36; + modules-right = ["mpris" "pulseaudio" "clock" "tray" "battery"]; + clock = { + format = "πŸ“… {:%a %b-%d %I:%M %p}"; + }; + pulseaudio = { + format-muted = "πŸ”‡ {volume}"; + format = "{icon} {volume}"; + format-icons.default = ["πŸ”ˆ" "πŸ”‰" "πŸ”Š"]; + on-click = "${pkgs.pavucontrol}/bin/pavucontrol"; + }; + mpris = { + format = "{player_icon} {artist} - {title}"; + format-paused = "{status_icon} {player_icon} {artist} - {title}"; + player-icons = { + default = "▢️"; + mpd = "🎡"; + kdeconnect = "☎️"; + }; + status-icons = { + paused = "⏸️"; + }; + }; + battery = { + format = "{icon} {capacity}%"; + format-icons = ["🀏" "πŸͺ«" "πŸ”‹" "πŸ”‹"]; + format-charging = "πŸ”Œ {capacity}%"; + states = { + warning = 30; + critical = 15; + }; + }; + }; + }; + systemd = { + enable = true; + target = "graphical-session.target"; + }; + }; + + + +}