diff --git a/flake.lock b/flake.lock index f76436b..5d11b8c 100644 --- a/flake.lock +++ b/flake.lock @@ -174,6 +174,48 @@ "type": "github" } }, + "hyprland": { + "inputs": { + "hyprland-protocols": "hyprland-protocols", + "nixpkgs": "nixpkgs_2", + "wlroots": "wlroots", + "xdph": "xdph" + }, + "locked": { + "lastModified": 1686680001, + "narHash": "sha256-JPcudWZ2bBwkJofGTV23NyXw/wo7PyiLFIdqPfrzxHE=", + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "7762ac0173b860af83e58d56409f9cf0fa7252e9", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "Hyprland", + "type": "github" + } + }, + "hyprland-protocols": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1684265364, + "narHash": "sha256-AxNnWbthsuNx73HDQr0eBxrcE3+yfl/WsaXZqUFmkpQ=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "8c279b9fb0f2b031427dc5ef4eab53f2ed835530", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, "idris-emacs-src": { "flake": false, "locked": { @@ -420,6 +462,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1686501370, + "narHash": "sha256-G0WuM9fqTPRc2URKP9Lgi5nhZMqsfHGrdEbrLvAPJcg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "75a5ebf473cd60148ba9aec0d219f72e5cf52519", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1685801374, "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", @@ -435,7 +493,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1667292599, "narHash": "sha256-7ISOUI1aj6UKMPIL+wwthENL22L3+A9V+jS8Is3QsRo=", @@ -451,7 +509,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_5": { "locked": { "lastModified": 1667085676, "narHash": "sha256-jPHYYoSdrV3ypWG4oi9SUeI2MU6dLjxM88+9io5Rrx0=", @@ -542,12 +600,13 @@ "emacs": "emacs", "flake-utils": "flake-utils_2", "home-manager": "home-manager", + "hyprland": "hyprland", "idris2": "idris2", "java": "java", "nix-on-droid": "nix-on-droid", "nixos-generators": "nixos-generators", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "nixpkgs-unstable": "nixpkgs-unstable", "quilt-server": "quilt-server", "scripts": "scripts", @@ -558,7 +617,7 @@ "scripts": { "inputs": { "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_4", "swaywm-toggler": "swaywm-toggler" }, "locked": { @@ -600,7 +659,7 @@ "swaywm-toggler": { "inputs": { "flake-utils": "flake-utils_5", - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_5" }, "locked": { "lastModified": 1667366374, @@ -677,6 +736,24 @@ "type": "github" } }, + "wlroots": { + "flake": false, + "locked": { + "host": "gitlab.freedesktop.org", + "lastModified": 1686573751, + "narHash": "sha256-5vnFxEMvn4wzT+XKR5Jo8VSn1hXrdf/mWuTmdHhRFBs=", + "owner": "wlroots", + "repo": "wlroots", + "rev": "6e8fb5509f2c94d09d4efa0f9b1f40b37bf73863", + "type": "gitlab" + }, + "original": { + "host": "gitlab.freedesktop.org", + "owner": "wlroots", + "repo": "wlroots", + "type": "gitlab" + } + }, "wsl": { "inputs": { "flake-compat": "flake-compat", @@ -698,6 +775,31 @@ "repo": "NixOS-WSL", "type": "github" } + }, + "xdph": { + "inputs": { + "hyprland-protocols": [ + "hyprland", + "hyprland-protocols" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1685385764, + "narHash": "sha256-r+XMyOoRXq+hlfjayb+fyi9kq2JK48TrwuNIAXqlj7U=", + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "rev": "4d9ff0c17716936e0b5ca577a39e263633901ed1", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 2c45b35..cd441db 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,7 @@ url = "github:nix-community/home-manager/release-23.05"; inputs.nixpkgs.follows = "nixpkgs"; }; + hyprland.url = "github:hyprwm/Hyprland"; nix-on-droid = { url = "github:t184256/nix-on-droid"; inputs = { @@ -53,7 +54,8 @@ }; outputs = { self, nixpkgs, nixpkgs-unstable, flake-utils, sops-nix - , home-manager, darwin, nixos-generators, wsl, nix-on-droid, ... }@inputs: + , home-manager, hyprland, darwin, nixos-generators, wsl, nix-on-droid, ... + }@inputs: let makeNixosSystem = { system, hostName, extraModules ? [ ], ourNixpkgs ? nixpkgs }: @@ -63,6 +65,7 @@ modules = [ sops-nix.nixosModules.sops home-manager.nixosModules.home-manager + hyprland.nixosModules.default ./modules/linux/default.nix ({ pkgs, lib, config, ... }: { # Configure hostname @@ -80,7 +83,10 @@ inputs = inputs; nixosConfig = config; }; - sharedModules = [ ./home-manager/linux/default.nix ]; + sharedModules = [ + ./home-manager/linux/default.nix + hyprland.homeManagerModules.default + ]; }; }) ] ++ extraModules; diff --git a/home-manager/linux/programs/sway.nix b/home-manager/linux/programs/sway.nix index 9692233..fdef285 100644 --- a/home-manager/linux/programs/sway.nix +++ b/home-manager/linux/programs/sway.nix @@ -54,9 +54,141 @@ in with lib; { # For fancy x11 scaling sommelier # Polkit - polkit_gnome + libsForQt5.polkit-kde-agent ]; ######################### + ## Hyprland + ######################### + # Enable and configure hyperland + wayland.windowManager.hyprland = { + enable = true; + xwayland = { + enable = true; + hidpi = true; + }; + recommendedEnvironment = true; + systemdIntegration = false; + extraConfig = '' + env = XCURSOR_SIZE,24 + input { + kb_layout = us + kb_variant = + kb_model = + kb_options = + kb_rules = + follow_mouse = 1 + # sensitivity = 0 # -1.0 - 1.0, 0 means no modification. + } + + general { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + gaps_in = 5 + gaps_out = 20 + border_size = 2 + col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg + col.inactive_border = rgba(595959aa) + layout = dwindle + } + decoration { + rounding = 10 + blur = true + blur_size = 3 + blur_passes = 1 + blur_new_optimizations = true + drop_shadow = true + 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, 7, myBezier + animation = windowsOut, 1, 7, default, popin 80% + animation = border, 1, 10, default + animation = borderangle, 1, 8, default + animation = fade, 1, 7, default + animation = workspaces, 1, 6, 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 + } + + gestures { + workspace_swipe = false + } + + $mainMod = SUPER + + bind = $mainMod, Q, exec, alacritty + bind = $mainMod, C, killactive, + bind = $mainMod, M, exit, + bind = $mainMod, E, exec, dolphin + bind = $mainMod, V, togglefloating, + bind = $mainMod, R, exec, fuzzel -f "Iosevka Sans Quasi" -b "103c48ff" -S "adbcbcff" -s "184956ff" -t "72898fff" -B 5 -r 5 -C "ed8649ff" + bind = $mainMod, P, pseudo, # dwindle + bind = $mainMod, J, togglesplit, # dwindle + bind = $mainMod, Z, exec, ${swaylock-command} + + # Move focus with mainMod + arrow keys + bind = $mainMod, h, movefocus, l + bind = $mainMod, l, movefocus, r + bind = $mainMod, k, movefocus, u + bind = $mainMod, j, movefocus, d + + # Switch workspaces with mainMod + [0-9] + bind = $mainMod, 1, workspace, 1 + bind = $mainMod, 2, workspace, 2 + bind = $mainMod, 3, workspace, 3 + bind = $mainMod, 4, workspace, 4 + bind = $mainMod, 5, workspace, 5 + bind = $mainMod, 6, workspace, 6 + bind = $mainMod, 7, workspace, 7 + bind = $mainMod, 8, workspace, 8 + bind = $mainMod, 9, workspace, 9 + bind = $mainMod, 0, workspace, 10 + + # Move active window to a workspace with mainMod + SHIFT + [0-9] + bind = $mainMod SHIFT, 1, movetoworkspace, 1 + bind = $mainMod SHIFT, 2, movetoworkspace, 2 + bind = $mainMod SHIFT, 3, movetoworkspace, 3 + bind = $mainMod SHIFT, 4, movetoworkspace, 4 + bind = $mainMod SHIFT, 5, movetoworkspace, 5 + bind = $mainMod SHIFT, 6, movetoworkspace, 6 + bind = $mainMod SHIFT, 7, movetoworkspace, 7 + bind = $mainMod SHIFT, 8, movetoworkspace, 8 + bind = $mainMod SHIFT, 9, movetoworkspace, 9 + bind = $mainMod SHIFT, 0, movetoworkspace, 10 + + # Scroll through existing workspaces with mainMod + scroll + bind = $mainMod, mouse_down, workspace, e+1 + bind = $mainMod, mouse_up, workspace, e-1 + + # Move/resize windows with mainMod + LMB/RMB and dragging + bindm = $mainMod, mouse:272, movewindow + bindm = $mainMod, mouse:273, resizewindow + + # systemd integration + exec-once=dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP && sleep 1 && systemctl --user start hyprland-session.target + ''; + }; + + # systemd session target + # Specified manually so we can work around an issue with the loading + systemd.user.targets.hyprland-session = { + Unit = { + Description = "Hyprland compositor session"; + Documentation = [ "man:systemd.special(7)" ]; + BindsTo = [ "graphical-session.target" ]; + Wants = [ "graphical-session-pre.target" ]; + After = [ "graphical-session-pre.target" ]; + }; + }; + ######################### ## Sway ######################### wayland.windowManager.sway = let modifier = "Mod4"; @@ -68,11 +200,11 @@ in with lib; { gtk = true; }; extraSessionCommands = '' - # Make qt theming work - export QT_QPA_PLATFORMTHEME="qt5ct" - # Prepare for wob - export WOBSOCK="$XDG_RUNTIME_DIR/wob.sock" - rm -rf $WOBSOCK && mkfifo $WOBSOCK + # Make qt theming work + export QT_QPA_PLATFORMTHEME="qt5ct" + # Prepare for wob + export WOBSOCK="$XDG_RUNTIME_DIR/wob.sock" + rm -rf $WOBSOCK && mkfifo $WOBSOCK ''; config = { # Startup wob @@ -672,7 +804,7 @@ in with lib; { Service = { ExecStart = "${config.programs.waybar.package}/bin/waybar"; ExecReload = "${pkgs.coreutils}/bin/kill -SIGUSR2 $MAINPID"; - ExecstartPost = "${pkgs.coreutils}/bin/sleep 1"; + ExecStartPost = "${pkgs.coreutils}/bin/sleep 1"; Restart = "on-failure"; KillMode = "mixed"; }; diff --git a/machines/levitation/home.nix b/machines/levitation/home.nix index 02c6de7..a6ef407 100644 --- a/machines/levitation/home.nix +++ b/machines/levitation/home.nix @@ -35,26 +35,14 @@ ]; }; - # Sway background - - # Spin up glpaper as a user service so we can have it restart on failure (liable due to kvm switch - # disconnecting input) - systemd.user.services.glpaper-dp1 = { - Unit = { - Description = "glpaper (DP-1)"; - After = [ "graphical-session.target" ]; - }; - Service = { - Type = "simple"; - ExecStart = '' - /etc/profiles/per-user/nathan/bin/glpaper DP-1 ${ - ../../custom-files/sway/selen.frag - } - ''; - Restart = "always"; - }; - Install = { WantedBy = [ "graphical-session.target" ]; }; - }; + # Hyprland outputs + wayland.windowManager.hyprland.extraConfig = '' + monitor=DP-1,preferred,auto,1.4,bitdepth,10 + input { + sensitivity = -0.3 + # accel_profile = flat + } + ''; # Gammastep services.gammastep = { diff --git a/modules/linux/default.nix b/modules/linux/default.nix index 3e1e6ec..23655b3 100644 --- a/modules/linux/default.nix +++ b/modules/linux/default.nix @@ -239,10 +239,12 @@ in { substituters = [ "https://nix-cache.mccarty.io/" "https://nix-community.cachix.org" + "https://hyprland.cachix.org" ]; trusted-public-keys = [ "nathan-nix-cache:R5/0GiItBM64sNgoFC/aSWuAopOAsObLcb/mwDf335A=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" ]; }; }; diff --git a/modules/linux/swaywm.nix b/modules/linux/swaywm.nix index 91d828b..ca6c239 100644 --- a/modules/linux/swaywm.nix +++ b/modules/linux/swaywm.nix @@ -58,6 +58,14 @@ in with lib; { wrapperFeatures.gtk = true; # package = null; }; + # Enable and configure hyperland + programs.hyprland = { + enable = true; + xwayland = { + enable = true; + hidpi = true; + }; + }; environment.sessionVariables = { MOZ_ENABLE_WAYLAND = "1"; };