{ lib, config, pkgs, machineProps, ... }: let gpu = config.my.hardware.gpu; anyWineUser = if machineProps.enableHomeManager then (builtins.any (user: user.my.games.wine.enable) (builtins.attrValues config.home-manager.users)) else false; in with lib; { options.my.hardware.gpu = mkOption { type = types.nullOr ( types.enum [ "nvidia" "intel" "amd" ] ); default = null; example = "nvidia"; description = '' The GPU type. ''; }; config = { boot.kernelParams = mkIf (gpu == "intel") [ "i915.enable_guc=2" ]; services.xserver.videoDrivers = mkIf (gpu == "nvidia") [ "nvidia" ]; hardware.graphics = { enable = gpu != null; enable32Bit = anyWineUser; extraPackages = with pkgs; [ (mkIf (gpu == "intel") intel-media-driver) (mkIf (gpu == "intel") intel-compute-runtime) ]; }; hardware.nvidia = mkIf (gpu == "nvidia") { open = true; package = config.boot.kernelPackages.nvidiaPackages.beta; }; }; }