From 83ebb840f3f9a7708b7831c469be86e8240c16b8 Mon Sep 17 00:00:00 2001 From: Gavin John Date: Fri, 18 Oct 2024 12:38:51 -0700 Subject: [PATCH] common/gpu/intel: reformat --- common/gpu/intel/comet-lake/default.nix | 4 +- common/gpu/intel/default.nix | 92 ++++++++++++----------- common/gpu/intel/elkhart-lake/default.nix | 4 +- common/gpu/intel/jasper-lake/default.nix | 4 +- common/gpu/intel/sandy-bridge/default.nix | 4 +- 5 files changed, 52 insertions(+), 56 deletions(-) diff --git a/common/gpu/intel/comet-lake/default.nix b/common/gpu/intel/comet-lake/default.nix index f5dd5ad6d..c4526f48f 100644 --- a/common/gpu/intel/comet-lake/default.nix +++ b/common/gpu/intel/comet-lake/default.nix @@ -1,7 +1,5 @@ { imports = [ ../. ]; - boot.kernelParams = [ - "i915.enable_guc=2" - ]; + boot.kernelParams = [ "i915.enable_guc=2" ]; } diff --git a/common/gpu/intel/default.nix b/common/gpu/intel/default.nix index 43e5ffa51..3a5c8d5ca 100644 --- a/common/gpu/intel/default.nix +++ b/common/gpu/intel/default.nix @@ -6,54 +6,58 @@ }: { imports = [ ../24.05-compat.nix ]; - options.hardware.intelgpu.driver = lib.mkOption { - description = "Intel GPU driver to use"; - type = lib.types.enum [ - "i915" - "xe" - ]; - default = "i915"; - }; - options.hardware.intelgpu.loadInInitrd = - lib.mkEnableOption "Load the Intel GPU kernel module at stage 1 boot. (Added to `boot.initrd.kernelModules`)" - // { - default = true; + options.hardware.intelgpu = { + driver = lib.mkOption { + description = "Intel GPU driver to use"; + type = lib.types.enum [ + "i915" + "xe" + ]; + default = "i915"; }; - config = { - boot.initrd.kernelModules = lib.optionals config.hardware.intelgpu.loadInInitrd [ - config.hardware.intelgpu.driver - ]; + loadInInitrd = + lib.mkEnableOption "Load the Intel GPU kernel module at stage 1 boot. (Added to `boot.initrd.kernelModules`)" + // { + default = true; + }; + }; - hardware.graphics.extraPackages = with pkgs; [ - ( - if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then - vaapiIntel - else - intel-vaapi-driver.override { enableHybridCodec = true; } - ) - intel-media-driver - ]; + config = + let + cfg = config.hardware.intelgpu; + in + { + boot.initrd.kernelModules = lib.optionals cfg.loadInInitrd [ cfg.driver ]; - hardware.graphics.extraPackages32 = with pkgs.driversi686Linux; [ - ( - if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then - vaapiIntel - else - intel-vaapi-driver.override { enableHybridCodec = true; } - ) - intel-media-driver - ]; + hardware.graphics.extraPackages = with pkgs; [ + ( + if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then + vaapiIntel + else + intel-vaapi-driver.override { enableHybridCodec = true; } + ) + intel-media-driver + ]; - assertions = [ - { - assertion = ( - config.hardware.intelgpu.driver != "xe" - || lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.8" - ); - message = "Intel Xe GPU driver is not supported on kernels earlier than 6.8. Update or use the i915 driver."; - } - ]; - }; + hardware.graphics.extraPackages32 = with pkgs.driversi686Linux; [ + ( + if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then + vaapiIntel + else + intel-vaapi-driver.override { enableHybridCodec = true; } + ) + intel-media-driver + ]; + + assertions = [ + { + assertion = ( + cfg.driver != "xe" || lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.8" + ); + message = "Intel Xe GPU driver is not supported on kernels earlier than 6.8. Update or use the i915 driver."; + } + ]; + }; } diff --git a/common/gpu/intel/elkhart-lake/default.nix b/common/gpu/intel/elkhart-lake/default.nix index f5dd5ad6d..c4526f48f 100644 --- a/common/gpu/intel/elkhart-lake/default.nix +++ b/common/gpu/intel/elkhart-lake/default.nix @@ -1,7 +1,5 @@ { imports = [ ../. ]; - boot.kernelParams = [ - "i915.enable_guc=2" - ]; + boot.kernelParams = [ "i915.enable_guc=2" ]; } diff --git a/common/gpu/intel/jasper-lake/default.nix b/common/gpu/intel/jasper-lake/default.nix index f5dd5ad6d..c4526f48f 100644 --- a/common/gpu/intel/jasper-lake/default.nix +++ b/common/gpu/intel/jasper-lake/default.nix @@ -1,7 +1,5 @@ { imports = [ ../. ]; - boot.kernelParams = [ - "i915.enable_guc=2" - ]; + boot.kernelParams = [ "i915.enable_guc=2" ]; } diff --git a/common/gpu/intel/sandy-bridge/default.nix b/common/gpu/intel/sandy-bridge/default.nix index 682815cee..47d6b9a87 100644 --- a/common/gpu/intel/sandy-bridge/default.nix +++ b/common/gpu/intel/sandy-bridge/default.nix @@ -3,7 +3,5 @@ # Enables RC6, RC6p and RC6pp. # Last two are only available on Sandy Bridge CPUs (circa 2011). - boot.kernelParams = [ - "i915.enable_rc6=7" - ]; + boot.kernelParams = [ "i915.enable_rc6=7" ]; }