From dc3942a8384ee8bf4f3d8778020cbf82afaa36c5 Mon Sep 17 00:00:00 2001 From: LarsZauberer Date: Fri, 12 Apr 2024 15:53:06 +0200 Subject: [PATCH] Minimal hyprland config --- flake.nix | 5 ++ hosts/lars/hyprland.nix | 79 +++++++++++++++++--- hosts/lars/kronos/configuration.nix | 6 ++ hosts/lars/kronos/default.nix | 6 ++ hosts/lars/kronos/hardware-configuration.nix | 11 +-- hosts/lars/kronos/profile.nix | 2 +- 6 files changed, 91 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index 9e56085..cc50691 100644 --- a/flake.nix +++ b/flake.nix @@ -28,5 +28,10 @@ url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + hyprland = { + url = "github:hyprwm/Hyprland"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; } diff --git a/hosts/lars/hyprland.nix b/hosts/lars/hyprland.nix index a4e2123..24afae1 100644 --- a/hosts/lars/hyprland.nix +++ b/hosts/lars/hyprland.nix @@ -1,21 +1,76 @@ -{ config, inputs, pkgs, ... }: -let +{ config, lib, inputs, pkgs, ... }: +with lib; let username = config.myOptions.other.system.username; + cfg = config.myOptions.hyprland; in { + options.myOptions.hyprland.nvidia.enable = mkEnableOption "nvidia"; + options.myOptions.hyprland.enable = mkEnableOption "hyprland"; + + config = mkIf cfg.enable { + environment.sessionVariables = mkIf cfg.nvidia.enable { + LIBVA_DRIVER_NAME = "nvidia"; + XDG_SESSION_TYPE = "wayland"; + GBM_BACKEND = "nvidia-drm"; + __GLX_VENDOR_LIBRARY_NAME = "nvidia"; + WLR_NO_HARDWARE_CURSORS = "1"; + SDL_VIDEODRIVER = "wayland"; + _JAVA_AWT_WM_NONREPARENTING = "1"; + CLUTTER_BACKEND = "wayland"; + WLR_RENDERER = "vulkan"; + XDG_CURRENT_DESKTOP = "Hyprland"; + XDG_SESSION_DESKTOP = "Hyprland"; + GTK_USE_PORTAL = "1"; + NIXOS_XDG_OPEN_USE_PORTAL = "1"; + }; programs.hyprland = { enable = true; xwayland.enable = true; }; + xdg.portal.wlr.enable = true; + xdg.portal.lxqt.enable = false; + systemd.user.services.xdg-desktop-portal-gnome.enable = false; - wayland.windowManager.hyprland = { - enable = true; - settings = { - "$mod" = "SUPER"; - bind = [ - "$mod, Q, killactive" - "$mod, return, kitty" - "$mod SHIFT, return, firefox" - ]; + home-manager.users.${username} = { + wayland.windowManager.hyprland = { + enable = true; + settings = { + "$mod" = "SUPER"; + + monitor = [ + "DP-2,2560x1440@144,0x0,1" + "DP-1,1920x1080@60,2560x0,1" + ]; + + input = { + kb_layout = "ch"; + }; + + bind = [ + "$mod, Q, killactive" + "$mod, return, exec, alacritty" + "$mod SHIFT, return, exec, firefox" + + # Monitor management + "$mod SHIFT, k, movecurrentworkspacetomonitor, DP-2" + "$mod SHIFT, j, movecurrentworkspacetomonitor, DP-1" + ] + ++ ( + builtins.concatLists (builtins.genList ( + x: let + ws = let + c = (x + 1) / 10; + in + builtins.toString (x+1-(c * 10)); + in [ + "$mod, ${ws}, workspace, ${toString (x+1)}" + "$mod SHIFT, ${ws}, movetoworkspace, ${toString(x + 1)}" + ] + ) + 10) + ); + }; + }; }; - }; + }; + } diff --git a/hosts/lars/kronos/configuration.nix b/hosts/lars/kronos/configuration.nix index d5a65ed..5d796f5 100644 --- a/hosts/lars/kronos/configuration.nix +++ b/hosts/lars/kronos/configuration.nix @@ -7,5 +7,11 @@ username = "lars"; }; }; + hyprland = { + enable = true; + nvidia.enable = true; + }; }; + + services.getty.autologinUser = "lars"; } diff --git a/hosts/lars/kronos/default.nix b/hosts/lars/kronos/default.nix index cf0eaab..30c5db4 100644 --- a/hosts/lars/kronos/default.nix +++ b/hosts/lars/kronos/default.nix @@ -1,6 +1,12 @@ _: { imports = [ ../. + ./../programs.nix + ./../hyprland.nix + ./programs.nix + ./configuration.nix + ./hardware-configuration.nix + ./profile.nix ./configuration.nix ./programs.nix ./hardware-configuration.nix diff --git a/hosts/lars/kronos/hardware-configuration.nix b/hosts/lars/kronos/hardware-configuration.nix index 8a45163..2a816fe 100644 --- a/hosts/lars/kronos/hardware-configuration.nix +++ b/hosts/lars/kronos/hardware-configuration.nix @@ -8,18 +8,18 @@ [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; fileSystems."/" = - { device = "/dev/disk/by-uuid/bca69c91-6f66-4b21-b90e-15b4bc21a405"; + { device = "/dev/disk/by-uuid/4d68fd1c-bfcf-44b8-b9a2-c27be0a4f4c3"; fsType = "ext4"; }; fileSystems."/boot" = - { device = "/dev/disk/by-uuid/8683-FD07"; + { device = "/dev/disk/by-uuid/0461-D6B4"; fsType = "vfat"; }; @@ -30,8 +30,9 @@ # still possible to use this option, but it's recommended to use it in conjunction # with explicit per-interface declarations with `networking.interfaces..useDHCP`. networking.useDHCP = lib.mkDefault true; - # networking.interfaces.enp1s0f0.useDHCP = lib.mkDefault true; - # networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true; + # networking.interfaces.enp6s0.useDHCP = lib.mkDefault true; + # networking.interfaces.enp7s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp5s0.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; diff --git a/hosts/lars/kronos/profile.nix b/hosts/lars/kronos/profile.nix index 40caaa7..30407f5 100644 --- a/hosts/lars/kronos/profile.nix +++ b/hosts/lars/kronos/profile.nix @@ -3,7 +3,7 @@ _: { ../../../options/boot/grub-boot.nix ../../../options/desktop/fonts.nix ../../../options/common/networking.nix - ../../options/common/gpu/nvidia.nix + ../../../options/common/gpu/nvidia.nix ../../../options/common/pin-registry.nix ../../../options/common/preserve-system.nix ];