Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivan/e916cf975135a95174203b51d72d6ef9 to your computer and use it in GitHub Desktop.
Save ivan/e916cf975135a95174203b51d72d6ef9 to your computer and use it in GitHub Desktop.
nixpkgs patch to build fewer kernel things
From 283f99d20990d094d74ac60b98e082a16511389b Mon Sep 17 00:00:00 2001
From: Ivan Kozik <ivan@ludios.org>
Date: Fri, 12 May 2023 02:18:33 +0000
Subject: [PATCH] linux/common-config: don't build things that we'll never use
---
.../linux/kernel/common-config.nix | 114 ++----------------
1 file changed, 8 insertions(+), 106 deletions(-)
diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix
index 6e704e2ad2ab..1fc5fd3858be 100644
--- a/pkgs/os-specific/linux/kernel/common-config.nix
+++ b/pkgs/os-specific/linux/kernel/common-config.nix
@@ -176,18 +176,12 @@ let
NET_CLS_BPF = module;
NET_ACT_BPF = module;
NET_SCHED = yes;
- L2TP_V3 = yes;
- L2TP_IP = module;
- L2TP_ETH = module;
BRIDGE_VLAN_FILTERING = yes;
BONDING = module;
NET_L3_MASTER_DEV = option yes;
NET_FOU_IP_TUNNELS = option yes;
IP_NF_TARGET_REDIRECT = module;
- PPP_MULTILINK = yes; # PPP multilink support
- PPP_FILTER = yes;
-
# needed for iwd WPS support (wpa_supplicant replacement)
KEY_DH_OPERATIONS = yes;
@@ -231,19 +225,9 @@ let
INET_RAW_DIAG = mkDefault module;
INET_DIAG_DESTROY = mkDefault yes;
- # enable multipath-tcp
- MPTCP = whenAtLeast "5.6" yes;
- MPTCP_IPV6 = whenAtLeast "5.6" yes;
- INET_MPTCP_DIAG = whenAtLeast "5.9" (mkDefault module);
-
# Kernel TLS
TLS = module;
TLS_DEVICE = whenAtLeast "4.18" yes;
-
- # infiniband
- INFINIBAND = module;
- INFINIBAND_IPOIB = module;
- INFINIBAND_IPOIB_CM = yes;
};
wireless = {
@@ -265,14 +249,6 @@ let
FB = yes;
FB_EFI = yes;
FB_NVIDIA_I2C = yes; # Enable DDC Support
- FB_RIVA_I2C = yes;
- FB_ATY_CT = yes; # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
- FB_ATY_GX = yes; # Mach64 GX support
- FB_SAVAGE_I2C = yes;
- FB_SAVAGE_ACCEL = yes;
- FB_SIS_300 = yes;
- FB_SIS_315 = yes;
- FB_3DFX_ACCEL = yes;
FB_VESA = yes;
FRAMEBUFFER_CONSOLE = yes;
FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER = whenAtLeast "4.19" yes;
@@ -410,12 +386,12 @@ let
TMPFS_POSIX_ACL = yes;
FS_ENCRYPTION = if (versionAtLeast version "5.1") then yes else option module;
- EXT2_FS_XATTR = yes;
- EXT2_FS_POSIX_ACL = yes;
- EXT2_FS_SECURITY = yes;
-
- EXT3_FS_POSIX_ACL = yes;
- EXT3_FS_SECURITY = yes;
+ EXT2_FS = no;
+ EXT3_FS = no;
+ REISERFS_FS = no;
+ JFS_FS = no;
+ XFS_FS = no;
+ F2FS_FS = no;
EXT4_FS_POSIX_ACL = yes;
EXT4_FS_SECURITY = yes;
@@ -425,28 +401,12 @@ let
NTFS3_LZX_XPRESS = whenAtLeast "5.15" yes;
NTFS3_FS_POSIX_ACL = whenAtLeast "5.15" yes;
- REISERFS_FS_XATTR = option yes;
- REISERFS_FS_POSIX_ACL = option yes;
- REISERFS_FS_SECURITY = option yes;
-
- JFS_POSIX_ACL = option yes;
- JFS_SECURITY = option yes;
-
- XFS_QUOTA = option yes;
- XFS_POSIX_ACL = option yes;
- XFS_RT = option yes; # XFS Realtime subvolume support
- XFS_ONLINE_SCRUB = option yes;
-
OCFS2_DEBUG_MASKLOG = option no;
BTRFS_FS_POSIX_ACL = yes;
UBIFS_FS_ADVANCED_COMPR = option yes;
- F2FS_FS = module;
- F2FS_FS_SECURITY = option yes;
- F2FS_FS_ENCRYPTION = whenOlder "5.1" yes;
- F2FS_FS_COMPRESSION = whenAtLeast "5.6" yes;
UDF_FS = module;
NFSD_V2_ACL = whenOlder "6.2" yes;
@@ -471,9 +431,6 @@ let
CIFS_ACL = whenOlder "5.3" yes;
CIFS_DFS_UPCALL = yes;
- CEPH_FSCACHE = yes;
- CEPH_FS_POSIX_ACL = yes;
-
SQUASHFS_FILE_DIRECT = yes;
SQUASHFS_DECOMP_MULTI_PERCPU = whenOlder "6.2" yes;
SQUASHFS_XATTR = yes;
@@ -581,9 +538,7 @@ let
};
staging = {
- # Enable staging drivers. These are somewhat experimental, but
- # they generally don't hurt.
- STAGING = yes;
+
};
proc-events = {
@@ -619,10 +574,7 @@ let
KVM_GUEST = yes;
KVM_MMIO = yes;
KVM_VFIO = yes;
- KSM = yes;
VIRT_DRIVERS = yes;
- # We need 64 GB (PAE) support for Xen guest support
- HIGHMEM64G = { optional = true; tristate = mkIf (!stdenv.is64bit) "y";};
VFIO_PCI_VGA = mkIf stdenv.is64bit yes;
@@ -632,37 +584,15 @@ let
VBOXGUEST = option no;
DRM_VBOXVIDEO = option no;
- XEN = option yes;
- XEN_DOM0 = option yes;
- PCI_XEN = option yes;
- HVC_XEN = option yes;
- HVC_XEN_FRONTEND = option yes;
- XEN_SYS_HYPERVISOR = option yes;
- SWIOTLB_XEN = option yes;
- XEN_BACKEND = option yes;
- XEN_BALLOON = option yes;
- XEN_BALLOON_MEMORY_HOTPLUG = option yes;
- XEN_EFI = option yes;
- XEN_HAVE_PVMMU = option yes;
- XEN_MCE_LOG = option yes;
- XEN_PVH = option yes;
- XEN_PVHVM = option yes;
- XEN_SAVE_RESTORE = option yes;
- XEN_SCRUB_PAGES = whenOlder "4.19" yes;
- XEN_SELFBALLOONING = whenOlder "5.3" yes;
-
# Enable device detection on virtio-mmio hypervisors
VIRTIO_MMIO_CMDLINE_DEVICES = yes;
};
media = {
- MEDIA_DIGITAL_TV_SUPPORT = yes;
MEDIA_CAMERA_SUPPORT = yes;
MEDIA_CONTROLLER = yes;
MEDIA_PCI_SUPPORT = yes;
MEDIA_USB_SUPPORT = yes;
- MEDIA_ANALOG_TV_SUPPORT = yes;
- VIDEO_STK1160_COMMON = module;
};
"9p" = {
@@ -823,10 +753,6 @@ let
AIC7XXX_DEBUG_ENABLE = no;
AIC94XX_DEBUG = no;
- BLK_DEV_INTEGRITY = yes;
-
- BLK_SED_OPAL = yes;
-
BSD_PROCESS_ACCT_V3 = yes;
SERIAL_DEV_BUS = yes; # enables support for serial devices
@@ -847,8 +773,6 @@ let
CLEANCACHE = whenOlder "5.17" (option yes);
CRASH_DUMP = option no;
- DVB_DYNAMIC_MINORS = option yes; # we use udev
-
EFI_STUB = yes; # EFI bootloader in the bzImage itself
EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER =
whenOlder "6.2" (whenAtLeast "5.8" yes); # initrd kernel parameter for EFI
@@ -878,7 +802,6 @@ let
LDM_PARTITION = yes;
LOGIRUMBLEPAD2_FF = yes; # Logitech Rumblepad 2 force feedback
LOGO = no; # not needed
- MEDIA_ATTACH = yes;
MEGARAID_NEWGEN = yes;
MLX5_CORE_EN = option yes;
@@ -918,9 +841,6 @@ let
SLAB_FREELIST_HARDENED = yes;
SLAB_FREELIST_RANDOM = yes;
- SLIP_COMPRESSED = yes; # CSLIP compressed headers
- SLIP_SMART = yes;
-
HWMON = yes;
THERMAL_HWMON = yes; # Hardware monitoring support
NVME_HWMON = whenAtLeast "5.5" yes; # NVMe drives temperature reporting
@@ -966,12 +886,6 @@ let
FSL_MC_UAPI_SUPPORT = mkIf (stdenv.hostPlatform.system == "aarch64-linux") (whenAtLeast "5.12" yes);
- ASHMEM = { optional = true; tristate = whenBetween "5.0" "5.18" "y";};
- ANDROID = { optional = true; tristate = whenBetween "5.0" "5.19" "y";};
- ANDROID_BINDER_IPC = { optional = true; tristate = whenAtLeast "5.0" "y";};
- ANDROID_BINDERFS = { optional = true; tristate = whenAtLeast "5.0" "y";};
- ANDROID_BINDER_DEVICES = { optional = true; freeform = whenAtLeast "5.0" "binder,hwbinder,vndbinder";};
-
TASKSTATS = yes;
TASK_DELAY_ACCT = yes;
TASK_XACCT = yes;
@@ -1009,21 +923,9 @@ let
FB_SIMPLE = yes;
} // optionalAttrs (versionAtLeast version "5.4" && (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "aarch64-linux")) {
- # Required for various hardware features on Chrome OS devices
- CHROME_PLATFORMS = yes;
- CHROMEOS_TBMC = module;
-
- CROS_EC = module;
- CROS_EC_I2C = module;
- CROS_EC_SPI = module;
- CROS_EC_LPC = module;
- CROS_EC_ISHTP = module;
-
- CROS_KBD_LED_BACKLIGHT = module;
} // optionalAttrs (versionAtLeast version "5.4" && stdenv.hostPlatform.system == "x86_64-linux") {
- CHROMEOS_LAPTOP = module;
- CHROMEOS_PSTORE = module;
+
};
};
in
--
2.40.1
@ivan
Copy link
Author

ivan commented May 12, 2023

Size reduction (Linux 6.1.28 is my first build with this patch)

-rwxr-xr-x 1 root root  8,652,096 2023-05-12 15:56 kwscica7hjdhphsabk3a3l84x4y54an4-linux-6.1.27-bzImage.efi*
-rwxr-xr-x 1 root root  8,255,840 2023-05-12 15:56 k60307ilj67x3sslpppgal3z06gkf9a1-linux-6.1.28-bzImage.efi*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment