linux/common-config: conditionalize x86 specifics

This leads to fewer warnings when configuring a kernel for other
platforms, and will make it possible to validate configs for other
platforms like we do for pc.

Changed files
+52 -35
pkgs
os-specific
linux
+52 -35
pkgs/os-specific/linux/kernel/common-config.nix
···
# Enable CPU lockup detection
LOCKUP_DETECTOR = yes;
SOFTLOCKUP_DETECTOR = yes;
-
HARDLOCKUP_DETECTOR = yes;
+
HARDLOCKUP_DETECTOR = lib.mkIf (
+
with stdenv.hostPlatform; isPower || isx86 || lib.versionAtLeast version "6.5"
+
) yes;
# Enable streaming logs to a remote device over a network
NETCONSOLE = module;
···
MEMORY_FAILURE = yes;
# Collect ECC errors and retire pages that fail too often
-
RAS_CEC = yes;
+
RAS_CEC = lib.mkIf stdenv.hostPlatform.isx86 yes;
}
// lib.optionalAttrs (stdenv.hostPlatform.is32bit) {
# Enable access to the full memory range (aka PAE) on 32-bit architectures
···
FB_SIS_300 = yes;
FB_SIS_315 = yes;
FB_3DFX_ACCEL = yes;
-
FB_VESA = yes;
+
FB_VESA = lib.mkIf stdenv.hostPlatform.isx86 yes;
FRAMEBUFFER_CONSOLE = yes;
FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER = yes;
FRAMEBUFFER_CONSOLE_ROTATION = yes;
···
in
{
# compile in DRM so simpledrm can load before initrd if necessary
-
AGP = yes;
+
AGP = lib.mkIf (with stdenv.hostPlatform; isPower || isx86) yes;
DRM = yes;
DRM_LEGACY = whenOlder "6.8" no;
···
# Allow specifying custom EDID on the kernel command line
DRM_LOAD_EDID_FIRMWARE = yes;
-
VGA_SWITCHEROO = yes; # Hybrid graphics support
-
DRM_GMA500 = whenAtLeast "5.12" module;
-
DRM_GMA600 = whenOlder "5.13" yes;
-
DRM_GMA3600 = whenOlder "5.12" yes;
-
DRM_VMWGFX_FBCON = whenOlder "6.1" yes;
+
VGA_SWITCHEROO = lib.mkIf stdenv.hostPlatform.isx86 yes; # Hybrid graphics support
+
DRM_GMA500 = lib.mkIf stdenv.hostPlatform.isx86 (whenAtLeast "5.12" module);
+
DRM_GMA600 = lib.mkIf stdenv.hostPlatform.isx86 (whenOlder "5.13" yes);
+
DRM_GMA3600 = lib.mkIf stdenv.hostPlatform.isx86 (whenOlder "5.12" yes);
+
DRM_VMWGFX_FBCON = lib.mkIf stdenv.hostPlatform.isx86 (whenOlder "6.1" yes);
# (experimental) amdgpu support for verde and newer chipsets
DRM_AMDGPU_SI = yes;
# (stable) amdgpu support for bonaire and newer chipsets
···
DRM_AMD_DC_DCN1_0 = whenOlder "5.6" yes;
DRM_AMD_DC_DCN2_0 = whenOlder "5.6" yes;
DRM_AMD_DC_DCN2_1 = whenOlder "5.6" yes;
-
DRM_AMD_DC_DCN3_0 = whenBetween "5.9" "5.11" yes;
-
DRM_AMD_DC_DCN = whenBetween "5.11" "6.4" yes;
+
DRM_AMD_DC_DCN3_0 = lib.mkIf (with stdenv.hostPlatform; isx86) (whenBetween "5.9" "5.11" yes);
+
DRM_AMD_DC_DCN = lib.mkIf (with stdenv.hostPlatform; isx86 || isPower64) (
+
whenBetween "5.11" "6.4" yes
+
);
DRM_AMD_DC_FP = whenAtLeast "6.4" yes;
DRM_AMD_DC_HDCP = whenBetween "5.5" "6.4" yes;
DRM_AMD_DC_SI = whenAtLeast "5.10" yes;
···
DRM_AMD_ACP = yes;
# Enable AMD secure display when available
-
DRM_AMD_SECURE_DISPLAY = whenAtLeast "5.13" yes;
+
DRM_AMD_SECURE_DISPLAY = lib.mkIf (
+
with stdenv.hostPlatform;
+
(lib.versionAtLeast version "5.13" && (isx86 || isPower64))
+
|| (lib.versionAtLeast version "6.2" && isAarch64 && !stdenv.cc.isClang)
+
|| (lib.versionAtLeast version "6.5" && isLoongarch64 && !stdenv.cc.isClang)
+
|| (lib.versionAtLeast version "6.10" && isRiscV64 && !stdenv.cc.isClang)
+
) yes;
# Enable AMD image signal processor
DRM_AMD_ISP = whenAtLeast "6.11" yes;
···
};
microcode = {
-
MICROCODE = yes;
-
MICROCODE_INTEL = whenOlder "6.6" yes;
-
MICROCODE_AMD = whenOlder "6.6" yes;
+
MICROCODE = lib.mkIf stdenv.hostPlatform.isx86 yes;
+
MICROCODE_INTEL = lib.mkIf stdenv.hostPlatform.isx86 (whenOlder "6.6" yes);
+
MICROCODE_AMD = lib.mkIf stdenv.hostPlatform.isx86 (whenOlder "6.6" yes);
# Write Back Throttling
# https://lwn.net/Articles/682582/
# https://bugzilla.kernel.org/show_bug.cgi?id=12309#c655
···
virtualisation = {
PARAVIRT = option yes;
-
HYPERVISOR_GUEST = yes;
+
HYPERVISOR_GUEST = lib.mkIf stdenv.hostPlatform.isx86 yes;
PARAVIRT_SPINLOCKS = option yes;
-
KVM_ASYNC_PF = yes;
+
KVM_ASYNC_PF = lib.mkIf (with stdenv.hostPlatform; isS390 || isx86) yes;
KVM_GENERIC_DIRTYLOG_READ_PROTECT = yes;
-
KVM_GUEST = yes;
+
KVM_GUEST = lib.mkIf (with stdenv.hostPlatform; isPower || isx86) yes;
KVM_MMIO = yes;
KVM_VFIO = yes;
KSM = yes;
···
tristate = lib.mkIf (!stdenv.hostPlatform.is64bit) "y";
};
-
VFIO_PCI_VGA = lib.mkIf stdenv.hostPlatform.is64bit yes;
+
VFIO_PCI_VGA = lib.mkIf stdenv.hostPlatform.isx86_64 yes;
UDMABUF = yes;
···
# Allows soft-dirty tracking on pages, used by CRIU.
# See https://docs.kernel.org/admin-guide/mm/soft-dirty.html
-
MEM_SOFT_DIRTY = lib.mkIf (!stdenv.hostPlatform.isx86_32) yes;
+
MEM_SOFT_DIRTY = lib.mkIf (with stdenv.hostPlatform; isS390 || isPower64 || isx86_64) yes;
};
misc =
···
# stdenv.hostPlatform.linux-kernel.target assumes uncompressed on RISC-V.
KERNEL_UNCOMPRESSED = lib.mkIf stdenv.hostPlatform.isRiscV yes;
KERNEL_XZ = lib.mkIf (!stdenv.hostPlatform.isRiscV && !useZstd) yes;
-
KERNEL_ZSTD = lib.mkIf (!stdenv.hostPlatform.isRiscV && useZstd) yes;
+
KERNEL_ZSTD = lib.mkIf (
+
with stdenv.hostPlatform;
+
(isMips || isS390 || isx86 || (lib.versionAtLeast version "6.1" && isAarch64 || isLoongArch64))
+
&& useZstd
+
) yes;
HID_BATTERY_STRENGTH = yes;
# enabled by default in x86_64 but not arm64, so we do that here
···
# Allows debugging systems that get stuck during suspend/resume
PM_TRACE = yes;
-
PM_TRACE_RTC = yes;
+
PM_TRACE_RTC = lib.mkIf stdenv.hostPlatform.isx86 yes;
ACCESSIBILITY = yes; # Accessibility support
AUXDISPLAY = yes; # Auxiliary Display support
···
POSIX_MQUEUE = yes;
FRONTSWAP = whenOlder "6.6" yes;
FUSION = yes; # Fusion MPT device support
-
IDE = whenOlder "5.14" no; # deprecated IDE support, removed in 5.14
+
IDE = lib.mkIf (with stdenv.hostPlatform; isAarch32 || isM68k || isMips || isPower || isx86) (
+
whenOlder "5.14" no
+
); # deprecated IDE support, removed in 5.14
IDLE_PAGE_TRACKING = yes;
JOYSTICK_XPAD_FF = option yes; # X-Box gamepad rumble support
JOYSTICK_XPAD_LEDS = option yes; # LED Support for Xbox360 controller 'BigX' LED
-
KEYBOARD_APPLESPI = module;
+
KEYBOARD_APPLESPI = lib.mkIf stdenv.hostPlatform.isx86 module;
KEXEC_FILE = option yes;
KEXEC_JUMP = option yes;
···
MOUSE_ELAN_I2C_SMBUS = yes;
MOUSE_PS2_ELANTECH = yes; # Elantech PS/2 protocol extension
-
MOUSE_PS2_VMMOUSE = yes;
-
MTRR_SANITIZER = yes;
+
MOUSE_PS2_VMMOUSE = lib.mkIf stdenv.hostPlatform.isx86 yes;
+
MTRR_SANITIZER = lib.mkIf stdenv.hostPlatform.isx86 yes;
NET_FC = yes; # Fibre Channel driver support
# Needed for touchpads to work on some AMD laptops
PINCTRL_AMD = whenAtLeast "5.19" yes;
# GPIO on Intel Bay Trail, for some Chromebook internal eMMC disks
-
PINCTRL_BAYTRAIL = yes;
+
PINCTRL_BAYTRAIL = lib.mkIf stdenv.hostPlatform.isx86 yes;
# GPIO for Braswell and Cherryview devices
# Needs to be built-in to for integrated keyboards to function properly
-
PINCTRL_CHERRYVIEW = yes;
+
PINCTRL_CHERRYVIEW = lib.mkIf stdenv.hostPlatform.isx86 yes;
# 8 is default. Modern gpt tables on eMMC may go far beyond 8.
MMC_BLOCK_MINORS = freeform "32";
···
UEVENT_HELPER = no;
USERFAULTFD = yes;
-
X86_CHECK_BIOS_CORRUPTION = yes;
-
X86_MCE = yes;
+
X86_CHECK_BIOS_CORRUPTION = lib.mkIf stdenv.hostPlatform.isx86 yes;
+
X86_MCE = lib.mkIf stdenv.hostPlatform.isx86 yes;
RAS = yes; # Needed for EDAC support
···
PREEMPT = no;
PREEMPT_VOLUNTARY = yes;
-
X86_AMD_PLATFORM_DEVICE = yes;
-
X86_PLATFORM_DRIVERS_DELL = whenAtLeast "5.12" yes;
-
X86_PLATFORM_DRIVERS_HP = whenAtLeast "6.1" yes;
+
X86_AMD_PLATFORM_DEVICE = lib.mkIf stdenv.hostPlatform.isx86 yes;
+
X86_PLATFORM_DRIVERS_DELL = lib.mkIf stdenv.hostPlatform.isx86 (whenAtLeast "5.12" yes);
+
X86_PLATFORM_DRIVERS_HP = lib.mkIf stdenv.hostPlatform.isx86 (whenAtLeast "6.1" yes);
LIRC = yes;
···
CROS_EC = module;
CROS_EC_I2C = module;
CROS_EC_SPI = module;
-
CROS_EC_LPC = module;
-
CROS_EC_ISHTP = module;
CROS_KBD_LED_BACKLIGHT = module;
TCG_TIS_SPI_CR50 = whenAtLeast "5.5" yes;
···
CP15_BARRIER_EMULATION = lib.mkIf (stdenv.hostPlatform.system == "aarch64-linux") yes;
// lib.optionalAttrs (stdenv.hostPlatform.system == "x86_64-linux") {
+
CROS_EC_LPC = module;
+
CROS_EC_ISHTP = module;
+
CHROMEOS_LAPTOP = module;
CHROMEOS_PSTORE = module;