From 3eb09e6d9d916e295811fe3cc3743858249377f0 Mon Sep 17 00:00:00 2001
From: 0xTux <0xtux@pm.me>
Date: Wed, 14 Feb 2024 12:10:08 +0530
Subject: [PATCH] add hyprland
---
flake.nix | 3 +
modules/home-manager/hyprland/default.nix | 284 +++++++++++++++++
modules/home-manager/waybar/default.nix | 343 +++++++++++++++++++++
modules/nixos/desktop/awesome/default.nix | 8 +-
modules/nixos/desktop/hyprland/default.nix | 3 +
5 files changed, 637 insertions(+), 4 deletions(-)
create mode 100644 modules/home-manager/hyprland/default.nix
create mode 100644 modules/home-manager/waybar/default.nix
create mode 100644 modules/nixos/desktop/hyprland/default.nix
diff --git a/flake.nix b/flake.nix
index 657aae3..43c9d99 100755
--- a/flake.nix
+++ b/flake.nix
@@ -44,6 +44,7 @@
./hosts/canopus
./modules/nixos/desktop/awesome
+ ./modules/nixos/desktop/hyprland
./modules/nixos/virtualisation
./modules/nixos/steam.nix
@@ -54,6 +55,8 @@
home-manager.users.${username} = {
imports = [
./modules/home-manager
+ ./modules/home-manager/hyprland
+ ./modules/home-manager/waybar
./home/tux
];
};
diff --git a/modules/home-manager/hyprland/default.nix b/modules/home-manager/hyprland/default.nix
new file mode 100644
index 0000000..5116a8f
--- /dev/null
+++ b/modules/home-manager/hyprland/default.nix
@@ -0,0 +1,284 @@
+{ lib, pkgs, ... }: {
+
+ programs = {
+ waybar = {
+ enable = true;
+ };
+ };
+
+ wayland.windowManager.hyprland = {
+ enable = true;
+ xwayland.enable = true;
+ settings =
+ let
+ # Notify
+ notifycmd = "notify-send -h string:x-canonical-private-synchronous:hypr-cfg -u low";
+
+ # Elements
+ hypr_border_size = 2;
+ hypr_gaps_in = 5;
+ hypr_gaps_out = 10;
+ hypr_gaps_ws = -10;
+ hypr_rounding = 10;
+ groupbar_font_family = "Iosevka";
+ groupbar_font_size = 10;
+
+ # Colors
+ active_border_col = "rgba(90ceaaff) rgba(ecd3a0ff) 45deg";
+ inactive_border_col = "rgba(86aaeccc) rgba(93cee9cc) 45deg";
+ active_shadow_col = "0x66000000";
+ inactive_shadow_col = "0x66000000";
+ group_border_active_col = "rgba(90ceaaff) rgba(ecd3a0ff) 45deg";
+ group_border_inactive_col = "rgba(86aaeccc) rgba(93cee9cc) 45deg";
+ group_border_locked_active_col = "rgba(90ceaaff) rgba(ecd3a0ff) 45deg";
+ group_border_locked_inactive_col = "rgba(86aaeccc) rgba(93cee9cc) 45deg";
+ groupbar_text_color = "0xFFf1fcf9";
+ in
+ {
+ #-- General
+ general = {
+ border_size = hypr_border_size;
+ gaps_in = hypr_gaps_in;
+ gaps_out = hypr_gaps_out;
+ gaps_workspaces = hypr_gaps_ws;
+ "col.active_border" = active_border_col;
+ "col.inactive_border" = inactive_border_col;
+ layout = "master";
+ resize_on_border = true;
+ };
+
+ #-- Decoration
+ decoration = {
+ rounding = hypr_rounding;
+ active_opacity = 0.75;
+ inactive_opacity = 0.75;
+ fullscreen_opacity = 1.0;
+ drop_shadow = true;
+ shadow_range = 25;
+ shadow_render_power = 3;
+ "col.shadow" = active_shadow_col;
+ "col.shadow_inactive" = inactive_shadow_col;
+
+ blur = {
+ enabled = true;
+ size = 5;
+ passes = 4;
+ ignore_opacity = true;
+ xray = true;
+ special = true;
+ };
+ };
+
+ #-- Animations
+ animations = {
+ enabled = true;
+ first_launch_animation = true;
+ animation = [
+ "windowsIn,1,5,default,popin 0%"
+ "windowsOut,1,5,default,popin"
+ "windowsMove,1,5,default,slide"
+ "fadeIn,1,8,default"
+ "fadeOut,1,8,default"
+ "fadeSwitch,1,8,default"
+ "fadeShadow,1,8,default"
+ "fadeDim,1,8,default"
+ "border,1,10,default"
+ "borderangle,1,10,default"
+ "workspaces,1,5,default,slide"
+ "specialWorkspace,1,5,default,fade"
+ ];
+ };
+
+ #-- Input: Keyboard, Mouse, Touchpad
+ input = {
+ sensitivity = 0.5;
+ scroll_method = "2 fg";
+ natural_scroll = true;
+ touchpad = {
+ natural_scroll = true;
+ clickfinger_behavior = false;
+ };
+ };
+
+ #-- Group
+ group = {
+ "col.border_active" = group_border_active_col;
+ "col.border_inactive" = group_border_inactive_col;
+ "col.border_locked_active" = group_border_locked_active_col;
+ "col.border_locked_inactive" = group_border_locked_inactive_col;
+ groupbar = {
+ enabled = true;
+ font_family = groupbar_font_family;
+ font_size = groupbar_font_size;
+ text_color = groupbar_text_color;
+ "col.active" = group_border_active_col;
+ "col.inactive" = group_border_inactive_col;
+ "col.locked_active" = group_border_locked_active_col;
+ "col.locked_inactive" = group_border_locked_inactive_col;
+ };
+ };
+
+ #-- Miscellaneous
+ misc = {
+ disable_hyprland_logo = true;
+ force_hypr_chan = false;
+ force_default_wallpaper = 0;
+ focus_on_activate = true;
+ no_direct_scanout = false;
+ background_color = "0x000000";
+ };
+
+ #-- Output
+ monitor = ",preferred,auto,1";
+
+ #-- Layout : Dwindle
+ dwindle = {
+ pseudotile = false;
+ force_split = 0;
+ preserve_split = false;
+ smart_split = false;
+ smart_resizing = true;
+ permanent_direction_override = false;
+ special_scale_factor = 0.8;
+ split_width_multiplier = 1.0;
+ no_gaps_when_only = false;
+ use_active_for_splits = true;
+ default_split_ratio = 1.0;
+ };
+
+ #-- Layout : Master
+ master = {
+ allow_small_split = false;
+ special_scale_factor = 0.8;
+ mfact = 0.5;
+ new_is_master = false;
+ new_on_top = false;
+ no_gaps_when_only = false;
+ orientation = "left";
+ inherit_fullscreen = true;
+ always_center_master = false;
+ smart_resizing = true;
+ drop_at_cursor = true;
+ };
+
+ #-- Window Rules
+ windowrule = [ ];
+
+ #-- Keybindings
+ bind =
+ let
+ terminal = "alacritty";
+ browser = "firefox";
+ filemanager = "thunar";
+ editor = "geany";
+ in
+ [
+
+ # groups
+ "SUPER, G, togglegroup"
+ "SUPER, G, exec, ${notifycmd} 'Toggled Group Mode'"
+ "SUPER, H, changegroupactive, b"
+ "SUPER, L, changegroupactive, f"
+ "SUPER_SHIFT, L, lockactivegroup, toggle"
+ "SUPER_SHIFT, L, exec, ${notifycmd} 'Toggled Group Lock'"
+
+ # terminal
+ "SUPER, Return, exec, ${terminal}"
+
+ # apps
+ "SUPER_SHIFT, F, exec, ${filemanager}"
+ "SUPER_SHIFT, E, exec, ${editor}"
+ "SUPER_SHIFT, B, exec, ${browser}"
+
+ # hyprland
+ "SUPER, Q, killactive,"
+ "SUPER, C, killactive,"
+ "CTRL_ALT, Delete, exit,"
+ "SUPER, F, fullscreen, 0"
+ "SUPER, F, exec, ${notifycmd} 'Fullscreen Mode'"
+ "SUPER, S, pseudo,"
+ "SUPER, S, exec, ${notifycmd} 'Pseudo Mode'"
+ "SUPER, Space, togglefloating,"
+ "SUPER, Space, centerwindow,"
+
+ # change focus
+ "SUPER, left, movefocus, l"
+ "SUPER, right, movefocus, r"
+ "SUPER, up, movefocus, u"
+ "SUPER, down, movefocus, d"
+
+ # move active
+ "SUPER_SHIFT, left, movewindow, l"
+ "SUPER_SHIFT, right, movewindow, r"
+ "SUPER_SHIFT, up, movewindow, u"
+ "SUPER_SHIFT, down, movewindow, d"
+
+ # switch between windows
+ "SUPER,Tab,cyclenext,"
+ "SUPER,Tab,bringactivetotop,"
+
+ # workspaces
+ "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"
+
+ # send to workspaces
+ "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"
+
+ # seamless workspace switching
+ "CTRL_ALT, left, workspace, e-1"
+ "CTRL_ALT, right, workspace, e+1"
+ "CTRL_ALT_SHIFT, left, movetoworkspace, e-1"
+ "CTRL_ALT_SHIFT, right, movetoworkspace, e+1"
+
+ # change workspace mode
+ "SUPER_CTRL, F, workspaceopt, allfloat"
+ "SUPER_CTRL, F, exec, ${notifycmd} 'Toggled All Float Mode'"
+ "SUPER_CTRL, S, workspaceopt, allpseudo"
+ "SUPER_CTRL, S, exec, ${notifycmd} 'Toggled All Pseudo Mode'"
+
+ # misc
+ "SUPER_SHIFT, P, pin,"
+ "SUPER_SHIFT, P, exec, ${notifycmd} 'Toggled Pin'"
+ "SUPER_SHIFT, S, swapnext"
+ "SUPER_SHIFT, O, toggleopaque"
+ ];
+
+ binde = [
+ # resize active
+ "SUPER_CTRL, left, resizeactive, -20 0"
+ "SUPER_CTRL, right, resizeactive, 20 0"
+ "SUPER_CTRL, up, resizeactive, 0 -20"
+ "SUPER_CTRL, down, resizeactive, 0 20"
+
+ # move active (Floating Only)
+ "SUPER_ALT, left, moveactive, -20 0"
+ "SUPER_ALT, right, moveactive, 20 0"
+ "SUPER_ALT, up, moveactive, 0 -20"
+ "SUPER_ALT, down, moveactive, 0 20"
+ ];
+ bindm = [
+ # mouse buttons
+ "SUPER, mouse:272, movewindow"
+ "SUPER, mouse:273, resizewindow"
+ ];
+
+ "exec-once" = [
+ "${pkgs.swaybg}/bin/swaybg -i ~/Wallpapers/moments_before_desk.png"
+ "waybar"
+ ];
+ };
+ };
+}
diff --git a/modules/home-manager/waybar/default.nix b/modules/home-manager/waybar/default.nix
new file mode 100644
index 0000000..e234e9b
--- /dev/null
+++ b/modules/home-manager/waybar/default.nix
@@ -0,0 +1,343 @@
+{ pkgs, ... }: {
+
+ programs = {
+ waybar = {
+ enable = true;
+ settings = {
+ mainBar = {
+ position = "top";
+ layer = "top";
+ height = 35;
+ margin-top = 0;
+ margin-bottom = 0;
+ margin-left = 0;
+ margin-right = 0;
+ exclusive = true;
+ passthrough = false;
+
+ modules-left = [
+ "custom/l_end"
+ "cpu"
+ "memory"
+ "custom/r_end"
+ ];
+ modules-center = [
+ "custom/l_end"
+ "hyprland/workspaces"
+ "custom/r_end"
+ ];
+ modules-right = [
+ "custom/l_end"
+ "network"
+ "bluetooth"
+ "battery"
+ "tray"
+ "custom/r_end"
+ ];
+
+ "hyprland/workspaces" = {
+ "disable-scroll" = true;
+ "all-outputs" = true;
+ "active-only" = false;
+ "on-click" = "activate";
+ "persistent-workspaces" = {
+ "1" = [ ];
+ "2" = [ ];
+ "3" = [ ];
+ "4" = [ ];
+ };
+ };
+
+ "network" = {
+ "tooltip" = true;
+ "format-wifi" = " {bandwidthDownBytes} {bandwidthUpBytes}";
+ "format-ethernet" = " {bandwidthDownBytes} {bandwidthUpBytes}";
+ "tooltip-format" = "Network= {essid}\nSignal strength= {signaldBm}dBm ({signalStrength}%)\nFrequency= {frequency}MHz\nInterface= {ifname}\nIP= {ipaddr}/{cidr}\nGateway= {gwaddr}\nNetmask= {netmask}";
+ "format-linked" = " {ifname} (No IP)";
+ "format-disconnected" = " ";
+ "tooltip-format-disconnected" = "Disconnected";
+ "interval" = 2;
+ };
+
+ "battery" = {
+ "states" = {
+ "good" = 95;
+ "warning" = 30;
+ "critical" = 20;
+ };
+ "format" = "{icon} {capacity}%";
+ "format-charging" = " {capacity}%";
+ "format-plugged" = " {capacity}%";
+ "format-alt" = "{time} {icon}";
+ "format-icons" = [ "" "" "" "" "" "" "" "" "" "" "" ];
+ };
+
+ "bluetooth" = {
+ "format" = "";
+ "format-disabled" = "";
+ "format-connected" = " {num_connections}";
+ "format-connected-battery" = "{icon} {num_connections}";
+ # "format-connected-battery"= "{icon} {device_alias}-{device_battery_percentage}%";
+ "format-icons" = [ "" "" "" "" "" "" "" "" "" "" "" ];
+ # "format-device-preference"= [ "device1"; "device2" ]; // preference list deciding the displayed device If this config option is not defined or none of the devices in the list are connected; it will fall back to showing the last connected device.
+ "tooltip-format" = "{controller_alias}\n{num_connections} connected";
+ "tooltip-format-connected" = "{controller_alias}\n{num_connections} connected\n\n{device_enumerate}";
+ "tooltip-format-enumerate-connected" = "{device_alias}";
+ "tooltip-format-enumerate-connected-battery" = "{device_alias}\t{icon} {device_battery_percentage}%";
+ };
+
+ "memory" = {
+ "states" = {
+ "c" = 90; # critical
+ "h" = 60; # high
+ "m" = 30; # medium
+ };
+ "interval" = 30;
+ "format" = " {used}GB";
+ "format-m" = " {used}GB";
+ "format-h" = " {used}GB";
+ "format-c" = " {used}GB";
+ "format-alt" = " {percentage}%";
+ "max-length" = 10;
+ "tooltip" = true;
+ "tooltip-format" = " {percentage}%\n {used=0.1f}GB/{total=0.1f}GB";
+ };
+
+ "cpu" = {
+ "interval" = 10;
+ "format" = " {usage}%";
+ "format-alt" = "{icon0}{icon1}{icon2}{icon3}";
+ "format-icons" = [ "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" ];
+ };
+
+ "tray" = {
+ "icon-size" = 14;
+ "spacing" = 5;
+ };
+
+ "custom/l_end" = {
+ "format" = " ";
+ "interval" = "once";
+ "tooltip" = false;
+ };
+
+ "custom/r_end" = {
+ "format" = " ";
+ "interval" = "once";
+ "tooltip" = false;
+ };
+
+ "custom/sl_end" = {
+ "format" = " ";
+ "interval" = "once";
+ "tooltip" = false;
+ };
+
+ "custom/sr_end" = {
+ "format" = " ";
+ "interval" = "once";
+ "tooltip" = false;
+ };
+
+ "custom/rl_end" = {
+ "format" = " ";
+ "interval" = "once";
+ "tooltip" = false;
+ };
+
+ "custom/rr_end" = {
+ "format" = " ";
+ "interval" = "once";
+ "tooltip" = false;
+ };
+
+ "custom/padd" = {
+ "format" = " ";
+ "interval" = "once";
+ "tooltip" = false;
+ };
+
+ };
+ };
+ style =
+ let
+ bar_bg = "rgba(23, 28, 34, 0.95)";
+ main_bg = "#101419";
+ main_fg = "#93cee9";
+
+ wb_act_bg = "#90ceaa";
+ wb_act_fg = "#1f2328";
+
+ wb_hvr_bg = "#90ceaa";
+ wb_hvr_fg = "#1f2328";
+ in
+ ''
+ * {
+ border: none;
+ border-radius: 0px;
+ font-family: "JetBrainsMono Nerd Font";
+ font-weight: bold;
+ font-size: 20px;
+ min-height: 10px;
+ }
+
+ window#waybar {
+ background: ${bar_bg};
+ }
+
+ tooltip {
+ background: ${main_bg};
+ color: ${main_fg};
+ border-radius: 7px;
+ border-width: 0px;
+ }
+
+ #workspaces button {
+ box-shadow: none;
+ text-shadow: none;
+ padding: 0px;
+ border-radius: 9px;
+ margin-top: 3px;
+ margin-bottom: 3px;
+ margin-left: 0px;
+ padding-left: 3px;
+ padding-right: 3px;
+ margin-right: 0px;
+ color: ${main_fg};
+ animation: ws_normal 20s ease-in-out 1;
+ }
+
+ #workspaces button.active {
+ background: ${wb_act_bg};
+ color: ${wb_act_fg};
+ margin-left: 3px;
+ padding-left: 12px;
+ padding-right: 12px;
+ margin-right: 3px;
+ animation: ws_active 20s ease-in-out 1;
+ transition: all 0.4s cubic-bezier(.55,-0.68,.48,1.682);
+ }
+
+ #workspaces button:hover {
+ background: ${wb_hvr_bg};
+ color: ${wb_hvr_fg};
+ animation: ws_hover 20s ease-in-out 1;
+ transition: all 0.3s cubic-bezier(.55,-0.68,.48,1.682);
+ }
+
+ #taskbar button {
+ box-shadow: none;
+ text-shadow: none;
+ padding: 0px;
+ border-radius: 9px;
+ margin-top: 3px;
+ margin-bottom: 3px;
+ margin-left: 0px;
+ padding-left: 3px;
+ padding-right: 3px;
+ margin-right: 0px;
+ color: @wb-color;
+ animation: tb_normal 20s ease-in-out 1;
+ }
+
+ #taskbar button.active {
+ background: ${wb_act_bg};
+ color: @wb-act-color;
+ margin-left: 3px;
+ padding-left: 12px;
+ padding-right: 12px;
+ margin-right: 3px;
+ animation: tb_active 20s ease-in-out 1;
+ transition: all 0.4s cubic-bezier(.55,-0.68,.48,1.682);
+ }
+
+ #taskbar button:hover {
+ background: ${wb_hvr_bg};
+ color: @wb-hvr-color;
+ animation: tb_hover 20s ease-in-out 1;
+ transition: all 0.3s cubic-bezier(.55,-0.68,.48,1.682);
+ }
+
+ #backlight,
+ #battery,
+ #bluetooth,
+ #custom-cliphist,
+ #clock,
+ #custom-cpuinfo,
+ #cpu,
+ #custom-gpuinfo,
+ #idle_inhibitor,
+ #language,
+ #memory,
+ #custom-mode,
+ #mpris,
+ #network,
+ #custom-power,
+ #pulseaudio,
+ #custom-spotify,
+ #taskbar,
+ #tray,
+ #custom-updates,
+ #custom-wallchange,
+ #custom-wbar,
+ #window,
+ #workspaces,
+ #custom-l_end,
+ #custom-r_end,
+ #custom-sl_end,
+ #custom-sr_end,
+ #custom-rl_end,
+ #custom-rr_end {
+ color: ${main_fg};
+ background: ${main_bg};
+ opacity: 1;
+ margin: 4px 0px 4px 0px;
+ padding-left: 4px;
+ padding-right: 4px;
+ }
+
+ #workspaces,
+ #taskbar {
+ padding: 0px;
+ }
+
+ #custom-r_end {
+ border-radius: 0px 21px 21px 0px;
+ margin-right: 9px;
+ padding-right: 3px;
+ }
+
+ #custom-l_end {
+ border-radius: 21px 0px 0px 21px;
+ margin-left: 9px;
+ padding-left: 3px;
+ }
+
+ #custom-sr_end {
+ border-radius: 0px;
+ margin-right: 9px;
+ padding-right: 3px;
+ }
+
+ #custom-sl_end {
+ border-radius: 0px;
+ margin-left: 9px;
+ padding-left: 3px;
+ }
+
+ #custom-rr_end {
+ border-radius: 0px 7px 7px 0px;
+ margin-right: 9px;
+ padding-right: 3px;
+ }
+
+ #custom-rl_end {
+ border-radius: 7px 0px 0px 7px;
+ margin-left: 9px;
+ padding-left: 3px;
+ }
+ '';
+ };
+ };
+
+}
diff --git a/modules/nixos/desktop/awesome/default.nix b/modules/nixos/desktop/awesome/default.nix
index 662a630..d3bafad 100755
--- a/modules/nixos/desktop/awesome/default.nix
+++ b/modules/nixos/desktop/awesome/default.nix
@@ -4,10 +4,10 @@
enable = true;
displayManager = {
sddm.enable = true;
- autoLogin = {
- enable = true;
- user = "${username}";
- };
+ # autoLogin = {
+ # enable = true;
+ # user = "${username}";
+ # };
};
windowManager.awesome = {
diff --git a/modules/nixos/desktop/hyprland/default.nix b/modules/nixos/desktop/hyprland/default.nix
new file mode 100644
index 0000000..68f0f54
--- /dev/null
+++ b/modules/nixos/desktop/hyprland/default.nix
@@ -0,0 +1,3 @@
+{ ... }: {
+ programs.hyprland.enable = true;
+}