2024-04-11 20:15:47 +02:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
2024-07-30 20:42:59 +02:00
|
|
|
machineProps,
|
2024-04-11 20:15:47 +02:00
|
|
|
...
|
|
|
|
}:
|
2024-07-30 20:42:59 +02:00
|
|
|
let
|
2024-08-01 21:40:51 +02:00
|
|
|
gpu = config.my.hardware.gpu;
|
2024-08-02 23:44:40 +02:00
|
|
|
hwAccelerationOptionPath = if (machineProps.nixpkgs == "unstable") then "graphics" else "opengl";
|
|
|
|
enable32BitOptionName =
|
|
|
|
if (machineProps.nixpkgs == "unstable") then "enable32Bit" else "driSupport32Bit";
|
|
|
|
anyWineUser =
|
|
|
|
if machineProps.enableHomeManager then
|
|
|
|
(builtins.any (user: user.my.games.wine.enable) (builtins.attrValues config.home-manager.users))
|
|
|
|
else
|
|
|
|
false;
|
2024-07-30 20:42:59 +02:00
|
|
|
in
|
2023-10-22 17:12:42 +02:00
|
|
|
with lib;
|
|
|
|
{
|
2024-08-01 21:40:51 +02:00
|
|
|
options.my.hardware.gpu = mkOption {
|
2024-04-11 20:15:47 +02:00
|
|
|
type = types.nullOr (
|
|
|
|
types.enum [
|
|
|
|
"nvidia"
|
|
|
|
"intel"
|
|
|
|
"amd"
|
|
|
|
]
|
|
|
|
);
|
2023-10-22 17:12:42 +02:00
|
|
|
default = null;
|
|
|
|
example = "nvidia";
|
|
|
|
description = ''
|
|
|
|
The GPU type.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2024-08-01 21:40:51 +02:00
|
|
|
boot.kernelParams = mkIf (gpu == "intel") [ "i915.enable_guc=2" ];
|
2024-02-08 09:59:41 +01:00
|
|
|
|
2024-07-30 20:42:59 +02:00
|
|
|
# Small hack as this option path changes between 24.05 and unstable
|
|
|
|
hardware.${hwAccelerationOptionPath} = {
|
2024-08-01 21:40:51 +02:00
|
|
|
enable = gpu != null;
|
2024-08-02 23:44:40 +02:00
|
|
|
|
|
|
|
"${enable32BitOptionName}" = anyWineUser;
|
|
|
|
|
2023-10-22 17:12:42 +02:00
|
|
|
extraPackages = with pkgs; [
|
2024-08-01 21:40:51 +02:00
|
|
|
(mkIf (gpu == "intel") intel-media-driver)
|
|
|
|
(mkIf (gpu == "intel") intel-compute-runtime)
|
2023-10-22 17:12:42 +02:00
|
|
|
];
|
|
|
|
};
|
2024-08-02 23:44:40 +02:00
|
|
|
|
2023-10-22 17:12:42 +02:00
|
|
|
};
|
|
|
|
}
|