From e78f011441fd3b6d485e6936aa1f5bb270708083 Mon Sep 17 00:00:00 2001 From: m3tam3re Date: Thu, 6 Apr 2023 17:12:19 +0200 Subject: [PATCH] hyprland --- flake.lock | 104 ++++++++++- flake.nix | 26 ++- home/features/coding/default.nix | 2 +- home/features/desktop/default.nix | 11 +- home/features/desktop/hyprland/config.nix | 192 ++++++++++++++++++++ home/features/desktop/hyprland/default.nix | 10 + home/features/desktop/hyprland/monitors.nix | 0 home/features/gaming/default.nix | 1 - home/users/m3tam3re/m3-nix.nix | 3 +- hosts/m3-nix/default.nix | 38 +++- hosts/m3-nix/hardware-configuration.nix | 1 + hosts/m3-nix/services/default.nix | 8 +- hosts/m3-nix/services/flatpak.nix | 1 + hosts/m3-nix/services/udev.nix | 2 +- hosts/m3-nix/services/xserver.nix | 23 +-- 15 files changed, 381 insertions(+), 41 deletions(-) create mode 100644 home/features/desktop/hyprland/config.nix create mode 100644 home/features/desktop/hyprland/default.nix create mode 100644 home/features/desktop/hyprland/monitors.nix diff --git a/flake.lock b/flake.lock index f435b4f..69daac5 100644 --- a/flake.lock +++ b/flake.lock @@ -98,6 +98,48 @@ "type": "github" } }, + "hyprland": { + "inputs": { + "hyprland-protocols": "hyprland-protocols", + "nixpkgs": "nixpkgs_3", + "wlroots": "wlroots", + "xdph": "xdph" + }, + "locked": { + "lastModified": 1680783435, + "narHash": "sha256-Vm1QMU0U8xvJiPDct9NkcCr9X6jtTVGz84Mo9YyeXnk=", + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "a740e3e5174cfb4f572ec3b82291e5288f5fecc3", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "Hyprland", + "type": "github" + } + }, + "hyprland-protocols": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671839510, + "narHash": "sha256-+PY1qqJfmZzzROgcIY4I7AkCwpnC+qBIYk2eFoA9RWc=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "b8f55e02a328c47ed373133c52483bbfa20a1b75", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1677676435, @@ -147,6 +189,22 @@ } }, "nixpkgs_3": { + "locked": { + "lastModified": 1680487167, + "narHash": "sha256-9FNIqrxDZgSliGGN2XJJSvcDYmQbgOANaZA4UWnTdg4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "53dad94e874c9586e71decf82d972dfb640ef044", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { "locked": { "lastModified": 1679878071, "narHash": "sha256-7U5sTaebhjtlTYQI+q1FrbS2YXAhEsbLIcqirQ/kXJk=", @@ -167,7 +225,8 @@ "agenix": "agenix", "deploy-rs": "deploy-rs", "home-manager": "home-manager", - "nixpkgs": "nixpkgs_3", + "hyprland": "hyprland", + "nixpkgs": "nixpkgs_4", "nixpkgs-unstable": "nixpkgs-unstable" } }, @@ -200,6 +259,49 @@ "repo": "flake-utils", "type": "github" } + }, + "wlroots": { + "flake": false, + "locked": { + "host": "gitlab.freedesktop.org", + "lastModified": 1680629978, + "narHash": "sha256-2iVx5zqU2CpMgmtVadsHSkhkAsoxAWKQp6RQqt2OgQY=", + "owner": "wlroots", + "repo": "wlroots", + "rev": "835208db98a29431fa687c9506f4b43fe645ff65", + "type": "gitlab" + }, + "original": { + "host": "gitlab.freedesktop.org", + "owner": "wlroots", + "repo": "wlroots", + "type": "gitlab" + } + }, + "xdph": { + "inputs": { + "hyprland-protocols": [ + "hyprland", + "hyprland-protocols" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1673116118, + "narHash": "sha256-eR0yDSkR2XYMesfdRWJs25kAdXET2mbNNHu5t+KUcKA=", + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "rev": "d479c846531fd0e1d2357c9588b8310a2b859ef2", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 70bcd98..a767049 100644 --- a/flake.nix +++ b/flake.nix @@ -12,10 +12,11 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; deploy-rs.url = "github:serokell/deploy-rs"; + hyprland.url = "github:hyprwm/Hyprland"; }; - outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, agenix, deploy-rs - , ... }@inputs: + outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, hyprland + , agenix, deploy-rs, ... }@inputs: let inherit (self) outputs; lib = nixpkgs.lib; @@ -61,18 +62,33 @@ }) ]; }; + m3-nix = lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + allowUnfree + ./hosts/m3-nix + agenix.nixosModules.default + ({ config, pkgs, ... }: { + nixpkgs.overlays = [ overlay-unstable ]; + }) + ]; + }; }; homeConfigurations = { # Laptop "m3tam3re@m3-nix" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages."x86_64-linux"; - extraSpecialArgs = { # pass things to the home configuration + extraSpecialArgs = { inherit inputs; }; - modules = [ ./home/users/m3tam3re/m3-nix.nix allowUnfree ]; + modules = [ + ./home/users/m3tam3re/m3-nix.nix + allowUnfree + ]; + }; # Company Root Servera "m3tam3re@lkk-nix-1" = home-manager.lib.homeManagerConfiguration { - extraSpecialArgs = { # pass things to the home configuration + extraSpecialArgs = { # pass things to t }; modules = [ ./home/users/m3tam3re/lkk-nix-1.nix ]; }; diff --git a/home/features/coding/default.nix b/home/features/coding/default.nix index 51c8d99..2dbc19f 100644 --- a/home/features/coding/default.nix +++ b/home/features/coding/default.nix @@ -3,6 +3,6 @@ home.packages = with pkgs; [ - + python3 ]; } diff --git a/home/features/desktop/default.nix b/home/features/desktop/default.nix index 8dcdbf4..4e47909 100644 --- a/home/features/desktop/default.nix +++ b/home/features/desktop/default.nix @@ -4,6 +4,7 @@ ./crypto.nix ./design.nix ./espanso.nix + ./hyprland ./i3-gaps.nix ./extrafonts.nix ./media.nix @@ -33,25 +34,33 @@ blueberry brave brightnessctl + clipman + dunst feh flameshot + fuzzel gnome.file-roller gnome.seahorse gnome.vinagre gsettings-desktop-schemas + hyprpaper libnotify lxappearance nyxt pasystray pavucontrol picom + polkit_gnome qt5ct + qt6.qtwayland rustdesk + slurp unrar unzip usbutils v4l-utils - variety + wlogout + wl-clipboard xclip xdg-utils xdotool diff --git a/home/features/desktop/hyprland/config.nix b/home/features/desktop/hyprland/config.nix new file mode 100644 index 0000000..65662db --- /dev/null +++ b/home/features/desktop/hyprland/config.nix @@ -0,0 +1,192 @@ +{ home, colorscheme, wallpaper }: +let inherit (home.sessionVariables) TERMINAL BROWSER EDITOR; +in '' + monitor=eDP-1,preferred, 2560x0, auto + monitor=DP-2,preferred, 0x0, auto + exec-once = waybar + exec-once = wl-paste -p -t text --watch clipman store -P --histpath="~/.local/share/clipman-primary.json" + # Source a file (multi-file configs) + # source = ~/.config/hypr/myColors.conf + + # Some default env vars. + env = XCURSOR_SIZE,24 + env = WLR_NO_HARDWARE_CURSORS,1 + # For all categories, see https://wiki.hyprland.org/Configuring/Variables/ + input { + kb_layout = de + kb_variant = + kb_model = + kb_rules = + kb_options=ctrl:nocaps + follow_mouse = 1 + + touchpad { + natural_scroll = yes + } + + sensitivity = 0 # -1.0 - 1.0, 0 means no modification. + } + + general { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + col.active_border = rgb(44475a) rgb(bd93f9) 90deg + col.inactive_border = rgba(44475aaa) + col.group_border = rgba(282a36dd) + col.group_border_active = rgb(bd93f9) rgb(44475a) 90deg + + gaps_in = 5 + gaps_out = 5 + border_size = 1 + col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg + col.inactive_border = rgba(595959aa) + + layout = dwindle + } + + decoration { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + col.shadow = rgba(1E202966) + drop_shadow = yes + shadow_range = 60 + shadow_offset = 1 2 + shadow_render_power = 3 + shadow_scale = 0.97 + rounding = 8 + blur = yes + blur_size = 3 + blur_passes = 3 + blur_new_optimizations = on + active_opacity = 0.9 + inactive_opacity = 0.5 + drop_shadow = yes + shadow_range = 4 + shadow_render_power = 3 + } + + animations { + enabled = yes + + # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more + + 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 = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below + preserve_split = yes # you probably want this + } + + master { + # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more + new_is_master = true + } + + gestures { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + workspace_swipe = off + } + + # Example per-device config + # See https://wiki.hyprland.org/Configuring/Keywords/#executing for more + device:epic-mouse-v1 { + sensitivity = -0.5 + } + + # Example windowrule v1 + # windowrule = float, ^(kitty)$ + # Example windowrule v2 + # windowrulev2 = float,class:^(kitty)$,title:^(kitty)$ + # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more + windowrule = float, file_progress + windowrule = float, confirm + windowrule = float, dialog + windowrule = float, download + windowrule = float, notification + windowrule = float, error + windowrule = float, splash + windowrule = float, confirmreset + windowrule = float, title:Open File + windowrule = float, title:branchdialog + windowrule = float, Lxappearance + windowrule = float, Wofi + windowrule = animation none,Wofi + windowrule = float,viewnior + windowrule = float,feh + windowrule = float, pavucontrol-qt + windowrule = float, pavucontrol + windowrule = float, file-roller + windowrule = fullscreen, wlogout + windowrule = float, title:wlogout + windowrule = fullscreen, title:wlogout + windowrule = idleinhibit focus, mpv + windowrule = idleinhibit fullscreen, firefox + windowrule = float, title:^(Media viewer)$ + windowrule = float, title:^(Volume Control)$ + windowrule = float, title:^(Picture-in-Picture)$ + windowrule = size 800 600, title:^(Volume Control)$ + windowrule = move 75 44%, title:^(Volume Control)$ + + # See https://wiki.hyprland.org/Configuring/Keywords/ for more + $mainMod = SUPER + + # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more + bind = $mainMod, return, exec, alacritty -e tmux + bind = $mainMod control, t, exec, alacritty -e tmux attach + bind = $mainMod SHIFT, e, exec, emacsclient -n -c -e '(package-initialize)' + bind = $mainMod, Escape, exec, wlogout -p layer-shell + bind = $mainMod, Space, togglefloating + bind = $mainMod, q, killactive, + bind = $mainMod, M, exit, + bind= $mainMod, F, fullscreen + bind = $mainMod, E, exec, thunar + bind = $mainMod, V, togglefloating, + bind = $mainMod, D, exec, fuzzel + bind = $mainMod, P, pseudo, # dwindle + bind = $mainMod, J, togglesplit, # dwindle + + # Move focus with mainMod + arrow keys + bind = $mainMod, left, movefocus, l + bind = $mainMod, right, movefocus, r + bind = $mainMod, up, movefocus, u + bind = $mainMod, down, 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 +'' diff --git a/home/features/desktop/hyprland/default.nix b/home/features/desktop/hyprland/default.nix new file mode 100644 index 0000000..adfe88f --- /dev/null +++ b/home/features/desktop/hyprland/default.nix @@ -0,0 +1,10 @@ +{ inputs, config, lib, pkgs, ... }: { + imports = [ inputs.hyprland.homeManagerModules.default ]; + wayland.windowManager.hyprland = { + enable = true; + nvidiaPatches = true; + }; + programs.waybar.package = pkgs.waybar.overrideAttrs + (oa: { mesonFlags = (oa.mesonFlags or [ ]) ++ [ "-Dexperimental=true" ]; }); + programs.waybar.enable = true; +} diff --git a/home/features/desktop/hyprland/monitors.nix b/home/features/desktop/hyprland/monitors.nix new file mode 100644 index 0000000..e69de29 diff --git a/home/features/gaming/default.nix b/home/features/gaming/default.nix index 2fddfd5..0de9bb8 100644 --- a/home/features/gaming/default.nix +++ b/home/features/gaming/default.nix @@ -3,7 +3,6 @@ imports = [ ./sunshine.nix ]; - home.packages = with pkgs; [ gamescope goverlay diff --git a/home/users/m3tam3re/m3-nix.nix b/home/users/m3tam3re/m3-nix.nix index 687c46a..009afd5 100644 --- a/home/users/m3tam3re/m3-nix.nix +++ b/home/users/m3tam3re/m3-nix.nix @@ -8,7 +8,7 @@ ../../features/virtualization ../../features/services ]; - +nixpkgs.config.allowUnfree = true; features = { cli = { fish.enable = true; @@ -35,4 +35,5 @@ }; home.stateVersion = "22.11"; + } diff --git a/hosts/m3-nix/default.nix b/hosts/m3-nix/default.nix index 7a4f917..0155183 100644 --- a/hosts/m3-nix/default.nix +++ b/hosts/m3-nix/default.nix @@ -47,6 +47,10 @@ in { boot.loader.grub.device = "nodev"; boot.loader.grub.useOSProber = true; + hardware.tuxedo-keyboard.enable = true; + boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ]; + boot.kernelModules = [ "v4l2loopback" ]; + boot.kernelParams = [ "tuxedo_keyboard.mode=0" # https://github.com/tuxedocomputers/tuxedo-keyboard#kernelparam "tuxedo_keyboard.brightness=255" @@ -58,6 +62,7 @@ in { options kvm_intel nested=1 options kvm_intel emulate_invalid_guest_state=0 options kvm ignore_msrs=1 + options v4l2loopback exclusive_caps=1 max_buffers=2 ''; boot.initrd.luks.devices."luks-a7b1ba69-0951-4347-886e-4c0c24c2b871".keyFile = @@ -74,25 +79,44 @@ in { networking.networkmanager.enable = true; networking.wg-quick.interfaces = { wg0 = { - address = [ "10.13.13.4/24" ]; - dns = [ "192.168.178.75" ]; - privateKeyFile = "/root/wg/peer_m3arch/privatekey-peer_m3arch"; + address = [ "10.8.0.3/24" ]; + privateKeyFile = "/root/wg/peer_m3-nix/privatekey-peer_m3-nix"; + dns = [ "10.88.0.1" ]; peers = [{ - publicKey = "zA3c0S33ZsX5oRMRCrNDYg6pCMLdRurLV+7cU2Chbwk="; + publicKey = "Il/nVlX2qzmZMJQ8QAKN+uQdkcK66Wt7MWZn9Vku6Tg="; + presharedKey = "sOgKQCXs+WAEpVvnkqTHlK1ItWpmP/xiexhAJ6oMBJs="; allowedIPs = [ "0.0.0.0/0" "::/0" ]; - endpoint = "45.132.245.244:51820"; + endpoint = "wg.lanakk.com:51820"; persistentKeepalive = 25; }]; }; }; + services.avahi = { + enable = true; + nssmdns = true; + publish = { + addresses = true; + workstation = true; + userServices = true; + }; + }; + + programs.steam = { + enable = true; + remotePlay.openFirewall = true; + dedicatedServer.openFirewall = true; + }; + time.timeZone = "Europe/Berlin"; i18n.defaultLocale = "de_DE.utf8"; console.keyMap = "de"; - environment.systemPackages = [ nvidia-offload nvim ]; - + environment.systemPackages = [ nvidia-offload neovim ]; + nix.extraOptions = '' + experimental-features = nix-command + ''; nix = { settings = { experimental-features = "nix-command flakes"; }; gc = { diff --git a/hosts/m3-nix/hardware-configuration.nix b/hosts/m3-nix/hardware-configuration.nix index 62d70c9..bf51559 100644 --- a/hosts/m3-nix/hardware-configuration.nix +++ b/hosts/m3-nix/hardware-configuration.nix @@ -56,4 +56,5 @@ # high-resolution display hardware.video.hidpi.enable = lib.mkDefault true; hardware.bluetooth.enable = true; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; } diff --git a/hosts/m3-nix/services/default.nix b/hosts/m3-nix/services/default.nix index 9a5de27..03ad6c0 100644 --- a/hosts/m3-nix/services/default.nix +++ b/hosts/m3-nix/services/default.nix @@ -8,10 +8,10 @@ ./xserver.nix ]; - services.gvfs = { - enable = true; - package = pkgs.gnome3.gvfs; - }; +# services.gvfs = { +# enable = true; +# package = pkgs.gnome3.gvfs; +# }; services.kubo = { enable = true; }; # IPFS services.printing.enable = true; services.netbird.enable = true; diff --git a/hosts/m3-nix/services/flatpak.nix b/hosts/m3-nix/services/flatpak.nix index 10c5eac..ee5dfc4 100644 --- a/hosts/m3-nix/services/flatpak.nix +++ b/hosts/m3-nix/services/flatpak.nix @@ -1,3 +1,4 @@ +{ pkgs, ... }: { services.flatpak.enable = true; xdg.portal = { # xdg desktop intergration (required for flatpak) diff --git a/hosts/m3-nix/services/udev.nix b/hosts/m3-nix/services/udev.nix index 07dac18..21ca259 100644 --- a/hosts/m3-nix/services/udev.nix +++ b/hosts/m3-nix/services/udev.nix @@ -1,4 +1,4 @@ -{ pkgs }: +{ pkgs, ... }: { services.udev.extraRules = '' diff --git a/hosts/m3-nix/services/xserver.nix b/hosts/m3-nix/services/xserver.nix index 82df80e..ce0b2b0 100644 --- a/hosts/m3-nix/services/xserver.nix +++ b/hosts/m3-nix/services/xserver.nix @@ -1,30 +1,15 @@ -{ pkgs }: - -{ +{ pkgs, ... }: { services.xserver = { enable = true; - exportConfiguration = true; - videoDrivers = [ "nvidia" ]; + videoDrivers = [ "nvidia" ]; displayManager = { - defaultSession = "xfce+i3"; - lightdm = { enable = true; }; - }; - desktopManager = { - xterm.enable = false; - xfce = { - enable = true; - noDesktop = true; - enableXfwm = false; - }; + defaultSession = "hyprland"; + sddm = { enable = true; }; }; libinput.enable = true; # touchpad support - windowManager.i3.package = pkgs.i3-gaps; - windowManager.i3.enable = true; layout = "de"; xkbOptions = "ctrl:nocaps"; }; - - programs.thunar.plugins = [ pkgs.xfce.thunar-archive-plugin ]; services.xserver.screenSection = '' Option "metamodes" "nvidia-auto-select +0+0 {ForceFullCompositionPipeline=On}" Option "AllowIndirectGLXProtocol" "off"