dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
commit b2d0434c43a06decf0adf3b42ae1777ef5bf51f8 parent 9e00aeb74bf380c092f24f0d51aa9eeff9c5c9c7 Author: maydayv7 <maydayv7@gmail.com> Date: Thu, 27 Mar 2025 23:04:58 +0530 feat: Nvidia dGPU Configuration Also use Hyprland as greeter again
Diffstat:
| M | devices/valkyrie/default.nix | | | 2 | ++ |
| M | devices/valkyrie/drivers.nix | | | 34 | ++++------------------------------ |
| M | files/flake.nix | | | 3 | +++ |
| A | files/hyprland/greeter.conf | | | 21 | +++++++++++++++++++++ |
| M | modules/README.md | | | 1 | + |
| M | modules/gui/desktop/hyprland/apps/notify.nix | | | 7 | ++++++- |
| M | modules/gui/desktop/hyprland/default.nix | | | 33 | ++++++++++++++++++++++++++++----- |
| M | modules/gui/desktop/hyprland/settings/default.nix | | | 9 | ++------- |
| A | modules/hardware/gpu.nix | | | 55 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| M | modules/hardware/virtualisation/vfio.nix | | | 22 | +++++++--------------- |
10 files changed, 129 insertions(+), 58 deletions(-)
diff --git a/devices/valkyrie/default.nix b/devices/valkyrie/default.nix @@ -15,6 +15,7 @@ filesystem = "advanced"; support = ["laptop" "mobile" "printer" "virtualisation"]; modules = ["asus-zephyrus-ga402x-nvidia"]; + gpu = "nvidia"; cpu = { cores = 8; mode = "performance"; @@ -22,6 +23,7 @@ vm = { vfio = "setup"; + passthrough = ["10de:28e0" "10de:22be"]; android.enable = false; }; }; diff --git a/devices/valkyrie/drivers.nix b/devices/valkyrie/drivers.nix @@ -3,42 +3,16 @@ lib, ... }: let - inherit (lib) hasPrefix mkForce mkIf; - enable = config.hardware.vm.vfio != "on"; - mode = config.hardware.cpu.mode == "performance"; + inherit (lib) hasPrefix mkIf; in { services.fwupd.enable = true; - # Discrete GPU - services.xserver.videoDrivers = mkForce ["nvidia"]; + # https://gitlab.freedesktop.org/drm/amd/-/issues/3388 boot.kernelParams = [ - "nvidia_drm.fbdev=1" # Wayland Support - "NVreg_UsePageAttributeTable=1" # PAT Support - "NVreg_RegistryDwords=RMUseSwI2c=0x01;RMI2cSpeed=100" # DDC/CI Support - - # https://gitlab.freedesktop.org/drm/amd/-/issues/3388 - (mkIf mode "amdgpu.dcdebugmask=0x10") + (mkIf (config.hardware.cpu.mode == "performance") + "amdgpu.dcdebugmask=0x10") ]; - hardware = { - vm.passthrough = ["10de:28e0" "10de:22be"]; - nvidia = { - dynamicBoost = {inherit enable;}; - powerManagement = {inherit enable;}; - prime = { - nvidiaBusId = mkForce "PCI:1:0:0"; - amdgpuBusId = mkForce "PCI:101:0:0"; - - sync.enable = false; - reverseSync.enable = mkForce mode; - offload = { - enable = mkForce (!mode); - enableOffloadCmd = mkForce (!mode); - }; - }; - }; - }; - # Remap Keys services.udev.extraHwdb = '' evdev:name:Asus Keyboard:* diff --git a/files/flake.nix b/files/flake.nix @@ -77,6 +77,9 @@ # PcmanFM File Manager pcmanfm = readFile ./hyprland/pcmanfm.conf; + + # Greeter Configuration + greeter = readFile ./hyprland/greeter.conf; } // map.files { directory = ./hyprland/theme; diff --git a/files/hyprland/greeter.conf b/files/hyprland/greeter.conf @@ -0,0 +1,21 @@ +exec-once = @greeter; hyprctl dispatch exit + +windowrule = fullscreen, class:^(.*)$ +windowrule = stayfocused, class:^(.*)$ +monitor = , preferred, auto, 1 + +animations:enabled = false +misc { + background_color = rgb(@base00) + disable_autoreload = true + disable_hyprland_logo = true + disable_splash_rendering = true + disable_hyprland_qtutils_check = true + enable_anr_dialog = false + force_default_wallpaper = 0 +} + +ecosystem { + no_update_news = true + no_donation_nag = true +} diff --git a/modules/README.md b/modules/README.md @@ -66,6 +66,7 @@ Configuration [Builder](./configuration.nix) - `cpu` - - `cores`: Number of CPU Cores - Ex. `4` - `mode`: CPU Frequency Governor Mode - `"ondemand" / "performance" / "powersave"` + - `gpu`: Discrete GPU Support - `null / "nvidia"` - `filesystem`: Disk File System Choice - `"simple" / "advanced"` - - `persist`: System Files to Preserve across Reboots (while using `advanced` File System Layout) - `modules`: List of Hardware Configuration Modules imported from [`inputs.hardware`](https://github.com/nixos/nixos-hardware) - Ex. `[ "common-pc" ]` diff --git a/modules/gui/desktop/hyprland/apps/notify.nix b/modules/gui/desktop/hyprland/apps/notify.nix @@ -56,8 +56,13 @@ }; fullscreen_delay.fullscreen = "delay"; - power = {appname = "poweralertd";} // ignore; utility = {appname = "utility";} // ignore; + power = + { + appname = "poweralertd"; + icon = "preferences-system-power"; + } + // ignore; }; }; }; diff --git a/modules/gui/desktop/hyprland/default.nix b/modules/gui/desktop/hyprland/default.nix @@ -3,10 +3,11 @@ lib, util, pkgs, + files, ... } @ args: let inherit (config.gui) desktop; - inherit (lib) mkForce mkIf mkMerge; + inherit (lib) getExe mkForce mkIf mkMerge replaceStrings; theme = import ./theme.nix pkgs; in { ## Hyprland Configuration ## @@ -17,7 +18,7 @@ in { (util.map.modules.list ./apps)) ++ [ ## Environment Setup - { + rec { gui = { xorg.enable = false; wayland.enable = true; @@ -41,7 +42,6 @@ in { regreet = { enable = true; package = pkgs.greetd.regreet; - cageArgs = ["-s" "-m" "last"]; settings.commands = { reboot = ["systemctl" "reboot"]; poweroff = ["systemctl" "poweroff"]; @@ -49,8 +49,31 @@ in { }; }; - # Session - services.xserver.desktopManager.runXdgAutostartIfNone = true; + services = { + # Session + displayManager.defaultSession = "Desktop"; + xserver = { + desktopManager.runXdgAutostartIfNone = true; + displayManager.session = [ + { + name = "Desktop"; + manage = "desktop"; + start = "uwsm start -S -F Hyprland &> /dev/null"; + } + ]; + }; + + # Greeter + greetd.settings.default_session.command = with programs; + mkForce "${getExe hyprland.package} --config ${ + pkgs.writeText "greeter.conf" + (replaceStrings ["@greeter"] [(getExe regreet.package)] + (util.build.theme { + inherit (config.lib.stylix) colors; + file = files.hyprland.greeter; + })) + } &> /dev/null"; + }; } { # Greeter diff --git a/modules/gui/desktop/hyprland/settings/default.nix b/modules/gui/desktop/hyprland/settings/default.nix @@ -4,7 +4,7 @@ util, ... }: let - inherit (lib) mkForce mkIf optionals; + inherit (lib) mkForce mkIf; inherit (sys.gui) display fancy; inherit (sys.lib.stylix.colors) base03 base0A base0D; in { @@ -22,12 +22,7 @@ in { settings = { # GPU Support - env = - ["AQ_DRM_DEVICES, /dev/dri/card1:/dev/dri/card0"] - ++ optionals (builtins.elem "nvidia" sys.services.xserver.videoDrivers) [ - "LIBVA_DRIVER_NAME, nvidia" - "__GLX_VENDOR_LIBRARY_NAME, nvidia" - ]; + env = ["AQ_DRM_DEVICES, /dev/dri/card1:/dev/dri/card0"]; # Display monitor = ", preferred, auto, 1"; diff --git a/modules/hardware/gpu.nix b/modules/hardware/gpu.nix @@ -0,0 +1,55 @@ +{ + config, + lib, + ... +}: let + inherit (lib) mkForce mkIf mkMerge mkOption types; + cfg = config.hardware; +in { + options.hardware.gpu = mkOption { + description = "Discrete GPU Support"; + type = with types; nullOr (enum ["nvidia"]); + default = null; + }; + + config = mkMerge [ + (mkIf (cfg.gpu == "nvidia") { + services.xserver.videoDrivers = mkForce ["nvidia"]; + environment.variables = { + "__GLX_VENDOR_LIBRARY_NAME" = "nvidia"; + "LIBVA_DRIVER_NAME" = "nvidia"; + }; + + boot = { + blacklistedKernelModules = ["nouveau"]; + kernelModules = [ + "nvidia" + "nvidia_modeset" + "nvidia_uvm" + "nvidia_drm.fbdev=1" # Wayland Support + "NVreg_UsePageAttributeTable=1" # PAT Support + "NVreg_RegistryDwords=RMUseSwI2c=0x01;RMI2cSpeed=100" # DDC/CI Support + ]; + }; + + hardware.nvidia = let + enable = cfg.vm.vfio != "on"; + mode = cfg.cpu.mode == "performance"; + in { + modesetting.enable = mkForce true; + nvidiaSettings = mkForce true; + dynamicBoost = {inherit enable;}; + powerManagement = {inherit enable;}; + prime = with cfg.nvidia.prime; + mkIf (amdgpuBusId != "" || intelBusId != "") { + sync.enable = mkForce false; + reverseSync.enable = mkForce mode; + offload = { + enable = mkForce (!mode); + enableOffloadCmd = mkForce (!mode); + }; + }; + }; + }) + ]; +} diff --git a/modules/hardware/virtualisation/vfio.nix b/modules/hardware/virtualisation/vfio.nix @@ -5,7 +5,7 @@ ... }: let inherit (builtins) concatStringsSep elem; - inherit (lib) generators mkForce mkIf mkMerge mkOption optionals types; + inherit (lib) generators mkForce mkIf mkMerge mkOption types; enable = elem "virtualisation" config.hardware.support; cfg = config.hardware.vm; in { @@ -56,20 +56,12 @@ in { ("vfio-pci.ids=" + concatStringsSep "," cfg.passthrough) ]; - kernelModules = - [ - "vfio" - "vfio_pci" - "vfio_iommu_type1" - "vfio_virqfd" - ] - # GPU Passthrough - ++ optionals (elem "nvidia" config.services.xserver.videoDrivers) [ - "nvidia" - "nvidia_modeset" - "nvidia_uvm" - "nvidia_drm" - ]; + kernelModules = [ + "vfio" + "vfio_pci" + "vfio_iommu_type1" + "vfio_virqfd" + ]; }; # Looking Glass