Skip to content

Commit

Permalink
common/gpu/intel: nixfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandapip1 committed Oct 18, 2024
1 parent e559c1e commit 493ec09
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 56 deletions.
4 changes: 1 addition & 3 deletions common/gpu/intel/comet-lake/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
imports = [ ../. ];

boot.kernelParams = [
"i915.enable_guc=2"
];
boot.kernelParams = [ "i915.enable_guc=2" ];

hardware.intelgpu.vaapiDriver = "intel-media-driver";
}
123 changes: 79 additions & 44 deletions common/gpu/intel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
};
options.hardware.intelgpu.vaapiDriver = lib.mkOption {
description = "Intel VAAPI driver to use (use null to use both)";
type = lib.types.nullOr (lib.types.enum [
"intel-vaapi-driver"
"intel-media-driver"
]);
type = lib.types.nullOr (
lib.types.enum [
"intel-vaapi-driver"
"intel-media-driver"
]
);
default = null; # Use both drivers when we don't know which one to use
};
options.hardware.intelgpu.enableHybridCodec = lib.mkEnableOption "hybrid codec support for Intel GPUs";
Expand All @@ -37,52 +39,85 @@

nixpkgs.overlays = lib.optionals config.hardware.intelgpu.enableHybridCodec [
(
self: super: (
if pkgs?intel-vaapi-driver then {
intel-vaapi-driver = super.intel-vaapi-driver.override { enableHybridCodec = true; };
} else if pkgs?vaapiIntel then {
vaapiIntel = super.vaapiIntel.override { enableHybridCodec = true; };
} else
self: super:
(
if pkgs ? intel-vaapi-driver then
{ intel-vaapi-driver = super.intel-vaapi-driver.override { enableHybridCodec = true; }; }
else if pkgs ? vaapiIntel then
{ vaapiIntel = super.vaapiIntel.override { enableHybridCodec = true; }; }
else
builtins.throw "Unable to find Intel VAAPI driver"
)
)
];

hardware.graphics.extraPackages = lib.optionals (config.hardware.intelgpu.vaapiDriver == "intel-vaapi-driver" || config.hardware.intelgpu.vaapiDriver == null) (with pkgs; [
(
if pkgs?intel-vaapi-driver then
intel-vaapi-driver
else if pkgs?vaapiIntel then
vaapiIntel
else
builtins.throw "Unable to find Intel VAAPI driver"
)
]) ++ lib.optionals (config.hardware.intelgpu.vaapiDriver == "intel-media-driver" || config.hardware.intelgpu.vaapiDriver == null) (with pkgs; [
intel-media-driver
(
if pkgs?vpl-gpu-rt then
vpl-gpu-rt
else if pkgs?onevpl-intel-gpu then
onevpl-intel-gpu
else
builtins.throw "Unable to find OneAPI VAAPI driver"
)
]);
hardware.graphics.extraPackages =
lib.optionals
(
config.hardware.intelgpu.vaapiDriver == "intel-vaapi-driver"
|| config.hardware.intelgpu.vaapiDriver == null
)
(
with pkgs;
[
(
if pkgs ? intel-vaapi-driver then
intel-vaapi-driver
else if pkgs ? vaapiIntel then
vaapiIntel
else
builtins.throw "Unable to find Intel VAAPI driver"
)
]
)
++ lib.optionals
(
config.hardware.intelgpu.vaapiDriver == "intel-media-driver"
|| config.hardware.intelgpu.vaapiDriver == null
)
(
with pkgs;
[
intel-media-driver
(
if pkgs ? vpl-gpu-rt then
vpl-gpu-rt
else if pkgs ? onevpl-intel-gpu then
onevpl-intel-gpu
else
builtins.throw "Unable to find OneAPI VAAPI driver"
)
]
);

hardware.graphics.extraPackages32 = lib.optionals (config.hardware.intelgpu.vaapiDriver == "intel-vaapi-driver" || config.hardware.intelgpu.vaapiDriver == null) (with pkgs.driversi686Linux; [
(
if pkgs?intel-vaapi-driver then
intel-vaapi-driver
else if pkgs?vaapiIntel then
vaapiIntel
else
builtins.throw "Unable to find Intel VAAPI driver"
)
]) ++ lib.optionals (config.hardware.intelgpu.vaapiDriver == "intel-media-driver" || config.hardware.intelgpu.vaapiDriver == null) (with pkgs.driversi686Linux; ([
intel-media-driver
] ++ (lib.optionals (pkgs.driversi686Linux?vpl-gpu-rt) [
vpl-gpu-rt
])));
hardware.graphics.extraPackages32 =
lib.optionals
(
config.hardware.intelgpu.vaapiDriver == "intel-vaapi-driver"
|| config.hardware.intelgpu.vaapiDriver == null
)
(
with pkgs.driversi686Linux;
[
(
if pkgs ? intel-vaapi-driver then
intel-vaapi-driver
else if pkgs ? vaapiIntel then
vaapiIntel
else
builtins.throw "Unable to find Intel VAAPI driver"
)
]
)
++ lib.optionals
(
config.hardware.intelgpu.vaapiDriver == "intel-media-driver"
|| config.hardware.intelgpu.vaapiDriver == null
)
(
with pkgs.driversi686Linux;
([ intel-media-driver ] ++ (lib.optionals (pkgs.driversi686Linux ? vpl-gpu-rt) [ vpl-gpu-rt ]))
);

assertions = [
{
Expand Down
4 changes: 1 addition & 3 deletions common/gpu/intel/elkhart-lake/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
imports = [ ../. ];

boot.kernelParams = [
"i915.enable_guc=2"
];
boot.kernelParams = [ "i915.enable_guc=2" ];

hardware.intelgpu.vaapiDriver = "intel-media-driver";
}
4 changes: 1 addition & 3 deletions common/gpu/intel/jasper-lake/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
imports = [ ../. ];

boot.kernelParams = [
"i915.enable_guc=2"
];
boot.kernelParams = [ "i915.enable_guc=2" ];

hardware.intelgpu.vaapiDriver = "intel-media-driver";
}
4 changes: 1 addition & 3 deletions common/gpu/intel/sandy-bridge/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

# 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" ];

hardware.intelgpu.vaapiDriver = "intel-vaapi-driver";
}

0 comments on commit 493ec09

Please sign in to comment.