From 1dfd8be82d4e97cf9382d14a78ab707579d98855 Mon Sep 17 00:00:00 2001 From: cnst Date: Mon, 29 Jul 2024 18:54:22 +0200 Subject: [PATCH] incorporating hyprland into nix --- flake.lock | 63 +++++++-------- home/core/gui/hypr/default.nix | 17 ++--- home/core/gui/hypr/default.nixbak | 23 ++++++ home/core/gui/hypr/land/appearance.nix | 52 +++++++++++++ home/core/gui/hypr/land/inputs.nix | 72 ++++++++++++++++++ home/core/gui/hypr/land/keybinds.nix | 101 +++++++++++++++++++++++++ home/core/gui/hypr/land/rules.nix | 42 ++++++++++ home/core/gui/hypr/land/startup.nix | 20 +++++ nixos/hosts/cnix/default.nix | 4 + nixos/services/openssh/default.nix | 2 + nixos/services/xserver/cnix.nix | 1 + 11 files changed, 353 insertions(+), 44 deletions(-) create mode 100644 home/core/gui/hypr/default.nixbak create mode 100644 home/core/gui/hypr/land/appearance.nix create mode 100644 home/core/gui/hypr/land/inputs.nix create mode 100644 home/core/gui/hypr/land/keybinds.nix create mode 100644 home/core/gui/hypr/land/rules.nix create mode 100644 home/core/gui/hypr/land/startup.nix diff --git a/flake.lock b/flake.lock index 8c513080..32e04deb 100644 --- a/flake.lock +++ b/flake.lock @@ -27,12 +27,12 @@ "yafas": "yafas" }, "locked": { - "lastModified": 1722126515, - "narHash": "sha256-Pz8/0lFWhoHOReOJwbf4Fbx0ANGWc306QnuUeMR9keU=", - "rev": "d11e6cfcb6c09dbb9ae0265cfe7a684bcde02ec6", - "revCount": 1295, + "lastModified": 1722198001, + "narHash": "sha256-CC+hi1esCjv26J+Zryr+j5Vz2azEgS2lGIETEEnkI2o=", + "rev": "50e805f8d8255795063d8b0833590e5e05723fc9", + "revCount": 1299, "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/chaotic-cx/nyx/0.1.1295%2Brev-d11e6cfcb6c09dbb9ae0265cfe7a684bcde02ec6/0190f98b-9e53-7792-9075-57e87dc725d0/source.tar.gz" + "url": "https://api.flakehub.com/f/pinned/chaotic-cx/nyx/0.1.1299%2Brev-50e805f8d8255795063d8b0833590e5e05723fc9/0190fb02-a7d1-7e29-8ae0-8c0929f6f705/source.tar.gz" }, "original": { "type": "tarball", @@ -76,22 +76,17 @@ }, "devshell": { "inputs": { - "flake-utils": [ - "nixvim", - "nuschtosSearch", - "flake-utils" - ], "nixpkgs": [ "nixvim", "nixpkgs" ] }, "locked": { - "lastModified": 1721902368, - "narHash": "sha256-noQ5SghRPe0jzQEbFQb3fYbV6LZEzr7lIRQoxlU7fyI=", + "lastModified": 1722113426, + "narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=", "owner": "numtide", "repo": "devshell", - "rev": "cf8c7405479cfde7ea4dc815e195391d2328df10", + "rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae", "type": "github" }, "original": { @@ -111,11 +106,11 @@ ] }, "locked": { - "lastModified": 1722169575, - "narHash": "sha256-CaNEKMossqFI1tu0eK9vnGxHW/RlnnVZ2Naj5zugAoc=", + "lastModified": 1722259288, + "narHash": "sha256-DkzqDygV/Zs6rLDENsBmzUy3h7ti2VacmL6p4KDajac=", "owner": "nix-community", "repo": "flake-firefox-nightly", - "rev": "8972e28c3d04f475c3d3b9ac91292afe07581020", + "rev": "9617dbd27195b1ca6e9a752e4ec3723a87aad36e", "type": "github" }, "original": { @@ -448,11 +443,11 @@ ] }, "locked": { - "lastModified": 1722067813, - "narHash": "sha256-nxpzoKXwn+8RsxpxwD86mtEscOMw64ZD/vGSNWzGMlA=", + "lastModified": 1722119539, + "narHash": "sha256-2kU90liMle0vKR8exJx1XM4hZh9CdNgZGHCTbeA9yzY=", "owner": "nix-community", "repo": "home-manager", - "rev": "975b83ca560d17db51a66cb2b0dc0e44213eab27", + "rev": "d0240a064db3987eb4d5204cf2400bc4452d9922", "type": "github" }, "original": { @@ -468,11 +463,11 @@ ] }, "locked": { - "lastModified": 1722119539, - "narHash": "sha256-2kU90liMle0vKR8exJx1XM4hZh9CdNgZGHCTbeA9yzY=", + "lastModified": 1722203588, + "narHash": "sha256-91V5FMSQ4z9bkhTCf0f86Zjw0bh367daSf0mzCIW0vU=", "owner": "nix-community", "repo": "home-manager", - "rev": "d0240a064db3987eb4d5204cf2400bc4452d9922", + "rev": "792757f643cedc13f02098d8ed506d82e19ec1da", "type": "github" }, "original": { @@ -489,11 +484,11 @@ ] }, "locked": { - "lastModified": 1721852138, - "narHash": "sha256-JH8N5uoqoVA6erV4O40VtKKHsnfmhvMGbxMNDLtim5o=", + "lastModified": 1722119539, + "narHash": "sha256-2kU90liMle0vKR8exJx1XM4hZh9CdNgZGHCTbeA9yzY=", "owner": "nix-community", "repo": "home-manager", - "rev": "304a011325b7ac7b8c9950333cd215a7aa146b0e", + "rev": "d0240a064db3987eb4d5204cf2400bc4452d9922", "type": "github" }, "original": { @@ -609,11 +604,11 @@ ] }, "locked": { - "lastModified": 1721719500, - "narHash": "sha256-nnkqjv4Y37Hydjh6HE9wW4kSkV5Q7q4iIXlL5lwUFOw=", + "lastModified": 1722082646, + "narHash": "sha256-od8dBWVP/ngg0cuoyEl/w9D+TCNDj6Kh4tr151Aax7w=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "884f3fe6d9bf056ba0017c132c39c1f0d07d4fec", + "rev": "0413754b3cdb879ba14f6e96915e5fdf06c6aab6", "type": "github" }, "original": { @@ -755,11 +750,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1722111246, - "narHash": "sha256-5ikGEPb8oqup5tTWpvmC8V/ts9ss0VXsPNtlbz7IAYU=", + "lastModified": 1722232048, + "narHash": "sha256-TjBk/EECLYfPscxOW9yWEuoI4mzoYOok/qMiod/Xx8M=", "owner": "nix-community", "repo": "nixvim", - "rev": "59941a5300b1b13d6aac0a5115c8fc5b955b5405", + "rev": "2415edc0cb749bf81c9b142138c2bb705514f6cc", "type": "github" }, "original": { @@ -777,11 +772,11 @@ ] }, "locked": { - "lastModified": 1721548975, - "narHash": "sha256-agCbztdk1f7nCUz03R6xdbivuBRuqubP2RHW+MNuRTg=", + "lastModified": 1722144272, + "narHash": "sha256-olZbfaEdd+zNPuuyYcYGaRzymA9rOmth8yXOlVm+LUs=", "owner": "NuschtOS", "repo": "search", - "rev": "551b031e2bc0bcc9584347a8da6312e57169661d", + "rev": "16565307c267ec219c2b5d3494ba66df08e7d403", "type": "github" }, "original": { diff --git a/home/core/gui/hypr/default.nix b/home/core/gui/hypr/default.nix index 3bafd91b..ffda15d2 100644 --- a/home/core/gui/hypr/default.nix +++ b/home/core/gui/hypr/default.nix @@ -1,16 +1,13 @@ { + imports = [ + ./land/appearance.nix + ./land/inputs.nix + ./land/keybinds.nix + ./land/rules.nix + ./land/startup.nix + ]; wayland.windowManager.hyprland = { enable = true; - xwayland.enable = true; - settings = { - source = [ - "./land/appearance.conf" - "./land/inputs.conf" - "./land/keybinds.conf" - "./land/rules.conf" - "./land/startup.conf" - ]; - }; systemd = { variables = ["--all"]; diff --git a/home/core/gui/hypr/default.nixbak b/home/core/gui/hypr/default.nixbak new file mode 100644 index 00000000..3bafd91b --- /dev/null +++ b/home/core/gui/hypr/default.nixbak @@ -0,0 +1,23 @@ +{ + wayland.windowManager.hyprland = { + enable = true; + xwayland.enable = true; + settings = { + source = [ + "./land/appearance.conf" + "./land/inputs.conf" + "./land/keybinds.conf" + "./land/rules.conf" + "./land/startup.conf" + ]; + }; + + systemd = { + variables = ["--all"]; + extraCommands = [ + "systemctl --user stop graphical-session.target" + "systemctl --user start hyprland-session.target" + ]; + }; + }; +} diff --git a/home/core/gui/hypr/land/appearance.nix b/home/core/gui/hypr/land/appearance.nix new file mode 100644 index 00000000..557c48da --- /dev/null +++ b/home/core/gui/hypr/land/appearance.nix @@ -0,0 +1,52 @@ +{ + wayland.windowManager.hyprland.settings = { + general = { + gaps_in = 2; + gaps_out = 4; + border_size = 3; + #col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg + #col.inactive_border = rgba(595959aa) + "col.active_border" = "rgb(4c7a5d)"; # rgba(b16286ee) 45deg + "col.inactive_border" = "rgb(504945)"; + layout = "dwindle"; + allow_tearing = false; + resize_on_border = true; + }; + + decoration = { + rounding = 0; + blur = { + enabled = true; + size = 8; + passes = 1; + vibrancy = 0.1696; + }; + + drop_shadow = false; + shadow_range = 4; + shadow_render_power = 3; + # col.shadow = rgba(1a1a1aee) + }; + + animations = { + enabled = true; + bezier = [ + "myBezier,0.05, 0.9, 0.1, 1.05" + ]; + animation = [ + "windows, 1, 3, myBezier" + "windowsOut, 1, 3, default, popin 80%" + "border, 1, 3, default" + "borderangle, 1, 8, default" + "fade, 1, 7, default" + "workspaces, 1, 3, default" + ]; + }; + + dwindle = { + # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more + pseudotile = true; # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below + preserve_split = true; # you probably want this + }; + }; +} diff --git a/home/core/gui/hypr/land/inputs.nix b/home/core/gui/hypr/land/inputs.nix new file mode 100644 index 00000000..5bbce09c --- /dev/null +++ b/home/core/gui/hypr/land/inputs.nix @@ -0,0 +1,72 @@ +{ + wayland.windowManager.hyprland.settings = { + monitor = [ + "DP-3, 2560x1440@143.86, auto, auto" + "eDP-1,1920x1200@60.02,auto,1" + ]; + # Some default env vars. + # env = HYPRCURSOR_THEME,macOS + # env = HYPRCURSOR_SIZE,28 + # env = XCURSOR_THEME,macOS + # env = XCURSOR_SIZE,28 + + # For all categories, see https://wiki.hyprland.org/Configuring/Variables/ + input = { + follow_mouse = 1; + accel_profile = "flat"; + sensitivity = 0; # -1.0 - 1.0, 0 means no modification. + + touchpad = { + natural_scroll = true; + disable_while_typing = true; + clickfinger_behavior = true; + scroll_factor = 0.5; + }; + }; + # Desktop keyboard + device = [ + { + name = "pfu-limited-hhkb-hybrid"; + kb_layout = "hhkbse"; + kb_options = "lv3:rwin_switch"; + } + { + name = "hhkb-hybrid_1-keyboard"; + kb_layout = "hhkbse"; + kb_options = "lv3:rwin_switch"; + } + # Laptop keyboard + { + name = "at-translated-set-2-keyboard"; + kb_layout = "se"; + kb_options = "ctrl:swapcaps"; + } + ]; + gestures = { + workspace_swipe = true; + workspace_swipe_distance = 400; + workspace_swipe_fingers = 3; + workspace_swipe_cancel_ratio = 0.2; + workspace_swipe_min_speed_to_force = 5; + workspace_swipe_direction_lock = true; + workspace_swipe_direction_lock_threshold = 10; + workspace_swipe_create_new = true; + }; + misc = { + vrr = 1; + mouse_move_enables_dpms = 1; + key_press_enables_dpms = 0; + force_default_wallpaper = 0; + disable_hyprland_logo = true; + disable_splash_rendering = true; + }; + # xwayland { + # force_zero_scaling = true + # } + # cursor { + # no_hardware_cursors = true + # no_break_fs_vrr = true + # min_refresh_rate = 60 + # } + }; +} diff --git a/home/core/gui/hypr/land/keybinds.nix b/home/core/gui/hypr/land/keybinds.nix new file mode 100644 index 00000000..2d254f4d --- /dev/null +++ b/home/core/gui/hypr/land/keybinds.nix @@ -0,0 +1,101 @@ +# KEYBINDS +{ + wayland.windowManager.hyprland.settings = { + "$terminal" = "wezterm"; + "$fileManager" = "thunar"; + "$passwordManager" = "keepassxc"; + "$menu" = "pkill anyrun || anyrun | xargs hyprctl dispatch exec --"; + "$menuw" = "pkill anyrun || anyrun | xargs hyprctl dispatch exec --"; + "$browser" = "firefox-nightly"; + "$browserinc" = "firefox-nightly --private-window"; + "$ranger" = "rangerscript"; + + # See https://wiki.hyprland.org/Configuring/Keywords/ for more + "$mainMod" = "SUPER"; + + bind = [ + # Custom binds + "SUPER SHIFT, B, exec, pkill -SIGUSR2 waybar" # Reload waybar + + # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more + "SUPER, A, exec, pkill -SIGUSR1 waybar" + "SUPER, T, exec, $terminal" + "SUPER, W, exec, $browser" + "SUPER, K, exec, $passwordManager" + "SUPER SHIFT, W, exec, $browserinc" + "SUPER, Q, killactive," + #bind = SUPER, M, exec, hyprctl dispatch exit + #bind = SUPER, E, exec, $fileManager + "SUPER, E, exec, $fileManager" + "SUPER SHIFT, E, exec, $ranger" + "SUPER, F, fullscreen," + "SUPER SHIFT, F, togglefloating," + "SUPER, SPACE, exec, $menu" + "SUPER, P, pseudo," # dwindle + "SUPER, J, togglesplit," # dwindle + "SUPER, C, exec, hyprctl dispatch exec copyq toggle" + "SUPER, TAB, exec, $menuw" + + # Move focus with mainMod + arrow keys + "SUPER, left, movefocus, l" + "SUPER, right, movefocus, r" + "SUPER, up, movefocus, u" + "SUPER, down, movefocus, d" + + # Switch workspaces with mainMod + [0-9] + "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" + + # Move active window to a workspace with mainMod + SHIFT + [0-9] + "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" + + # Laptop controls + ",XF86AudioLowerVolume, exec, pamixer -d 5" + ",XF86AudioRaiseVolume, exec, pamixer -i 5" + ",XF86AudioMute, exec, pamixer -m" + ",XF86AudioMicMute, exec, pactl -- set-source-mute 0 toggle" + ",XF86MonBrightnessDown, exec, brightnessctl s 10%-" + ",XF86MonBrightnessUp, exec, brightnessctl s +10%" + + "SUPER, XF86MonBrightnessUp, exec, hyprctl dispatch dpms on" + "SUPER, XF86MonBrightnessDown, exec, hyprctl dispatch dpms off" + + # Screenshot a window + "SUPER, F10, exec, hyprshot -m window" + # Screenshot a monitor + ", F10, exec, hyprshot -m output" + # Screenshot a region + "SUPER SHIFT, F10, exec, hyprshot -m region" + + # Example special workspace (scratchpad) + "SUPER, S, togglespecialworkspace, magic" + "SUPER SHIFT, S, movetoworkspace, special:magic" + + # Scroll through existing workspaces with mainMod + scroll + # bind = SUPER, mouse_down, workspace, e+1 + # bind = SUPER, mouse_up, workspace, e-1 + ]; + # Move/resize windows with mainMod + LMB/RMB and dragging + bindm = [ + "SUPER, mouse:272, movewindow" + "SUPER, mouse:273, resizewindow" + ]; + }; +} diff --git a/home/core/gui/hypr/land/rules.nix b/home/core/gui/hypr/land/rules.nix new file mode 100644 index 00000000..c6ea8d91 --- /dev/null +++ b/home/core/gui/hypr/land/rules.nix @@ -0,0 +1,42 @@ +{ + wayland.windowManager.hyprland.settings = { + # CALCURSE SETTINGS + windowrulev2 = [ + "float,initialTitle:(floatcal)" + "size 843 650,initialTitle:(floatcal)" + "move 100%-w-20 40,initialTitle:(floatcal)" + #windowrulev2 = move 1708 32,class:(floatcal) + + # RANGER/NNN SETTINGS + "float,class:(floatranger)" + "float,class:(floatnnn)" + #windowrulev2 = size 843 650,class:(floatranger) + #windowrulev2 = move 1708 32,class:(floatranger) + #windowrulev2 = move 1708 32;size 843 650;dimaround;float,class:^(kitty)$,title:^(kitty)$ + # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more + "suppressevent maximize, class:.* # You'll probably like this." + #windowrulev2 = noshadow, floating:0 + "float,class:^(org.keepassxc.KeePassXC)$" + "center,class:^(org.keepassxc.KeePassXC)$" + "float,class:^(imv)$" + "float,class:^(com.github.hluk.copyq)$" + "float,class:^(blueman-manager)$" + "center,class:^(nwg-look)$" + "float,class:^(nwg-look)$" + "float,class:^(Lxappearance)$" + "float,class:(pavucontrol)$" + "move 100%-w-20 40,class:(pavucontrol)$" + "float,class:^(polkit-gnome-authentication-agent-1)$" + "float,class:^(org.gnome.Calculator)$" + "size 741 585,class:(pavucontrol)$" + "float,class:^(cnst.test)$" + "float,class:^(org.corectrl.CoreCtrl)$" + "float,class:^(feh)$" + ]; + windowrule = [ + "center, ^(xarchiver)$" + "float, ^(xarchiver)$" + "float, ^(org.gnome.FileRoller)$" + ]; + }; +} diff --git a/home/core/gui/hypr/land/startup.nix b/home/core/gui/hypr/land/startup.nix new file mode 100644 index 00000000..b7105e5f --- /dev/null +++ b/home/core/gui/hypr/land/startup.nix @@ -0,0 +1,20 @@ +{ + wayland.windowManager.hyprland.settings = { + exec-once = [ + # STARTUP + # exec-once = systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP + "systemctl --user start polkit-gnome-authentication-agent-1" + # exec-once = lxqt-policykit-agent & + "waybar" + "pamixer --set-volume 50" + "blueman-applet & udiskie -Nt" + "nm-applet --indicator" + "mullvad-vpn" + # exec-once = swaybg -i ~/media/images/wallpaper.png + "wl-clip-persist --clipboard regular --all-mime-type-regex '^(?!x-kde-passwordManagerHint).+'" + # exec-once = hyprctl dispatch exec "sleep 4s && copyq --start-server" + "hyprctl dispatch exec 'sleep 5s && keepassxc'" + "hyprctl dispatch exec 'sleep 3s && solaar -w hide'" + ]; + }; +} diff --git a/nixos/hosts/cnix/default.nix b/nixos/hosts/cnix/default.nix index b4d84b9a..fc67313f 100644 --- a/nixos/hosts/cnix/default.nix +++ b/nixos/hosts/cnix/default.nix @@ -77,6 +77,10 @@ in { pkiBundle = "/etc/secureboot"; }; + users.users.cnst.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGe3s7WbaM0aZTYHCE1ugiG/SxFXLSbWcLAWceFotpuh toothpick@nixos" + ]; + environment.sessionVariables = { FLAKE = "/home/cnst/.nix-config"; }; diff --git a/nixos/services/openssh/default.nix b/nixos/services/openssh/default.nix index cc414dbe..b5330504 100644 --- a/nixos/services/openssh/default.nix +++ b/nixos/services/openssh/default.nix @@ -1,7 +1,9 @@ { services.openssh = { enable = true; + ports = [22]; settings = { + AllowUsers = ["toothpick" "cnst"]; PermitRootLogin = "no"; PasswordAuthentication = false; }; diff --git a/nixos/services/xserver/cnix.nix b/nixos/services/xserver/cnix.nix index fb7c9eb0..9ed26a0c 100644 --- a/nixos/services/xserver/cnix.nix +++ b/nixos/services/xserver/cnix.nix @@ -1,6 +1,7 @@ {config, ...}: { services.xserver = { enable = true; + desktopManager.gnome.enable = true; videoDrivers = ["amdgpu"]; xkb = { extraLayouts.hhkbse = {