commit 904a0e1f5dba7dd8e2a9b0372ec7add7abe3a886
parent e9dd604049da1e3a66745aa5db4b18fe0207b3d8
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Fri, 27 Jun 2025 16:12:00 +0200
parent e9dd604049da1e3a66745aa5db4b18fe0207b3d8
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Fri, 27 Jun 2025 16:12:00 +0200
config/nixos/modules/hardware/video: refactor intel module, remove global enable flag
3 files changed, 18 insertions(+), 44 deletions(-)
diff --git a/config/nixos/modules/hardware/video/enable.nix b/config/nixos/modules/hardware/video/enable.nix @@ -1,23 +0,0 @@ -{ - pov, - config, - lib, - ... -}: -let - inherit (lib) types; - cfg = lib.getAttrFromPath pov config; - -in -{ - - option = { - type = types.bool; - default = false; - }; - - config = lib.mkIf cfg.enable { - hardware.graphics.enable = true; - }; - -}
diff --git a/config/nixos/modules/hardware/video/intel.nix b/config/nixos/modules/hardware/video/intel.nix @@ -1,5 +1,5 @@ { - pov, + povSelf, config, lib, pkgs, @@ -7,27 +7,23 @@ }: let inherit (lib) types; - cfg = lib.getAttrFromPath pov config; + cfg = lib.getAttrFromPath povSelf config; in { - options = { - enable = { - type = types.bool; - default = false; - }; + options.enable = { + type = types.bool; + default = false; }; - config = lib.mkIf (cfg.enable && cfg.intel.enable) { + config = lib.mkIf cfg.enable { boot.initrd.kernelModules = [ "i915" ]; - hardware.opengl = { + hardware.graphics = { enable = true; extraPackages = with pkgs; [ - vaapiIntel - vaapiVdpau - libvdpau-va-gl + vpl-gpu-rt intel-media-driver ]; };
diff --git a/config/nixos/modules/hardware/video/nvidia.nix b/config/nixos/modules/hardware/video/nvidia.nix @@ -1,13 +1,13 @@ { - pov, + povSelf, config, lib, ... }: let inherit (lib) types; - cfg = lib.getAttrFromPath pov config; - cfgRoot = lib.getAttrFromPath (lib.remove [ "hardware" "video" ] pov) config; + cfg = lib.getAttrFromPath povSelf config; + cfgRoot = lib.getAttrFromPath (lib.remove [ "hardware" "video" "nvidia" ] povSelf) config; in { @@ -64,12 +64,12 @@ in }; }; - config = lib.mkIf (cfg.enable && cfg.nvidia.enable) ( + config = lib.mkIf cfg.enable ( lib.mkMerge [ { assertions = [ { - assertion = !cfg.nvidia.open -> cfgRoot.modules.unfree.enable; + assertion = !cfg.open -> cfgRoot.modules.unfree.enable; message = '' The programs.nvidia module uses unfree software if open is set to false. To use it you need to @@ -105,6 +105,7 @@ in ]; hardware = { + graphics.enable = true; # NVIDIA nvidia = { inherit (cfg.nvidia) open; @@ -119,15 +120,15 @@ in # PowerManagement powerManagement.enable = cfg.powerManagement == "on" || cfg.powerManagement == "finegrained"; - powerManagement.finegrained = cfg.nvidia.powerManagement == "finegrained"; + powerManagement.finegrained = cfg.powerManagement == "finegrained"; # Integrated GPU prime = - if cfg.nvidia.integrated.enable then + if cfg.integrated.enable then { offload.enable = true; - "${config.hardware.cpu.vendor}BusId" = cfg.nvidia.integrated.integratedBus; - nvidiaBusId = cfg.nvidia.integrated.dedicatedBus; + "${config.hardware.cpu.vendor}BusId" = cfg.integrated.integratedBus; + nvidiaBusId = cfg.integrated.dedicatedBus; } else { };