moby: build the kernel with everything as a module

This commit is contained in:
2024-10-05 16:47:34 +00:00
parent 7590111b8f
commit e07ed5fe02
2 changed files with 279 additions and 274 deletions

View File

@@ -159,185 +159,188 @@ in
"rk8xx-i2c"
"rk8xx-spi"
# these can surely be reduced:
# "8250_dw"
# "adc_keys"
# "aes_ce_blk"
# "af_alg"
# "algif_hash"
# "algif_skcipher"
# "analogix_dp"
# "atkbd"
# "autofs4"
# "blake2b_generic"
# these were found to be loaded after the initrd, and at least one is needed.
# TODO: reduce this!
"8250_dw"
"adc_keys"
"aes_ce_blk"
"af_packet"
"analogix_dp"
"atkbd"
"autofs4"
"blake2b_generic"
"bluetooth"
# AVOID INCLUDING brcmfmac IN INITRD, ELSE WIFI FIRMWARE WILL FAIL TO LOAD
# "bluetooth"
# "bnep"
# "brcmfmac"
# "brcmutil"
# "btbcm"
# "btqca"
# "btrfs"
# "btsdio"
# "cec"
# "cfg80211"
# "chacha_neon"
# "clk_rk808"
# "cmdlinepart"
# "coresight"
# "coresight_cpu_debug"
# "coresight_etm4x"
# "cpufreq_ondemand"
# "cqhci"
# "crc16"
# "crc32c_generic"
# "crct10dif_ce"
# "crypto_engine"
# "dax"
# "dm_mod"
# "drm_display_helper"
# "drm_dma_helper"
# "drm_shmem_helper"
# "dw_hdmi"
# "dw_mipi_dsi"
# "dw_mmc"
# "dw_mmc_pltfm"
# "dw_mmc_rockchip"
# "dw_wdt"
# "ecc"
# "ecdh_generic"
# "efi_pstore"
# "evdev"
# "fan53555"
# "fat"
# "ff_memless"
# "fixed"
# "fuse"
# "gf128mul"
# "ghash_ce"
# "goodix_ts"
# "governor_simpleondemand"
# "gpio_keys"
# "gpio_rockchip"
# "gpio_vibra"
# "gpu_sched"
# "hantro_vpu"
# "hci_uart"
# "i2c_mux"
# "i2c_rk3x"
# "industrialio"
# "industrialio_triggered_buffer"
# "inv_mpu6050"
# "inv_mpu6050_i2c"
# "inv_mpu6050_spi"
# "inv_sensors_timestamp"
# "io_domain"
# "ip6_udp_tunnel"
# "ip6t_rpfilter"
# "ip_set"
# "ip_set_hash_ipport"
# "ip_tables"
# "ipt_rpfilter"
# "joydev"
# "kfifo_buf"
# "led_class"
# "led_class_multicolor"
# "leds_gpio"
# "leds_group_multicolor"
# "libchacha"
# "libchacha20poly1305"
# "libcrc32c"
# "libcurve25519_generic"
# "libdes"
# "libps2"
# "loop"
# "mc"
# "md5"
# "mmc_block"
# "mmc_core"
# "mousedev"
# "mtd"
# "nf_conntrack"
# "nf_defrag_ipv4"
# "nf_defrag_ipv6"
# "nf_log_syslog"
# "nf_tables"
# "nfnetlink"
# "nft_compat"
# "nls_cp437"
# "nls_iso8859_1"
# "nvmem_rockchip_efuse"
# "ofpart"
# "panel_himax_hx8394"
# "panfrost"
# "phy_rockchip_emmc"
# "pinctrl_rockchip"
# "pl330"
# "poly1305_neon"
# "polyval_ce"
# "polyval_generic"
# "pwm_bl"
# "pwm_rockchip"
# "pwrseq_core"
# "pwrseq_simple"
# "qrtr"
# "raid6_pq"
# "regmap_spi"
# "rfkill"
# "rk808_regulator"
# "rk8xx_core"
# "rk8xx_i2c"
# "rk_crypto"
# "rockchip_dfi"
# "rockchip_rga"
# "rockchip_saradc"
# "rockchip_thermal"
# "rockchip_vdec"
# "rockchipdrm"
# "rtc_rk808"
# "sch_fq_codel"
# "sdhci"
# "sdhci_of_arasan"
# "sdhci_pltfm"
# "serio"
# "sha1_ce"
# "sha256_arm64"
# "sha2_ce"
# "sm4"
# "snd"
# "snd_hrtimer"
# "snd_seq"
# "snd_seq_device"
# "snd_seq_dummy"
# "snd_timer"
# "soundcore"
# "spi_nor"
# "spi_rockchip"
# "udp_tunnel"
# "uio"
# "uio_pdrv_genirq"
# "v4l2_h264"
# "v4l2_jpeg"
# "v4l2_mem2mem"
# "v4l2_vp9"
# "vfat"
# "videobuf2_common"
# "videobuf2_dma_contig"
# "videobuf2_dma_sg"
# "videobuf2_memops"
# "videobuf2_v4l2"
# "videodev"
# "vivaldi_fmap"
# "wireguard"
# "x_tables"
# "xor"
# "xor_neon"
# "xt_LOG"
# "xt_conntrack"
# "xt_pkttype"
# "xt_set"
# "xt_tcpudp"
# "zram"
# "brcmfmac_wcc"
"brcmutil"
"btbcm"
"btqca"
"btrfs"
"btsdio"
"cec"
"cfg80211"
"chacha_neon"
"clk_rk808"
"coresight"
"coresight_cpu_debug"
"coresight_etm4x"
"cpufreq_ondemand"
"cqhci"
"crc16"
"crc32c_generic"
"crct10dif_ce"
"crypto_engine"
"drm_display_helper"
"drm_dma_helper"
"dw_hdmi"
"dw_mipi_dsi"
"dw_mmc"
"dw_mmc_pltfm"
"dw_mmc_rockchip"
"dw_wdt"
"ecc"
"ecdh_generic"
"efi_pstore"
"evdev"
"fan53555"
"fat"
"ff_memless"
"fixed"
"fuse"
"gf128mul"
"ghash_ce"
"goodix_ts"
"governor_simpleondemand"
"gpio_keys"
"gpio_rockchip"
"gpio_vibra"
"gpu_sched"
"hantro_vpu"
"hci_uart"
"i2c_mux"
"i2c_rk3x"
"industrialio"
"industrialio_triggered_buffer"
"inv_mpu6050"
"inv_mpu6050_i2c"
"inv_mpu6050_spi"
"inv_sensors_timestamp"
"io_domain"
"ip6t_rpfilter"
"ip6_udp_tunnel"
"ip_set"
"ip_set_hash_ipport"
"ip_tables"
"ipt_rpfilter"
"joydev"
"kfifo_buf"
"led_class"
"led_class_multicolor"
"leds_gpio"
"leds_group_multicolor"
"libchacha"
"libchacha20poly1305"
"libcrc32c"
"libcurve25519_generic"
"libdes"
"libps2"
"loop"
"mc"
"md5"
"mmc_block"
"mmc_core"
"mousedev"
"mtd"
"nf_conntrack"
"nf_defrag_ipv4"
"nf_defrag_ipv6"
"nf_log_syslog"
"nf_nat"
"nfnetlink"
"nf_tables"
"nft_chain_nat"
"nft_compat"
"nls_cp437"
"nls_iso8859_1"
"nvmem_rockchip_efuse"
"ofpart"
"panel_himax_hx8394"
"panfrost"
"phy_rockchip_emmc"
"pinctrl_rockchip"
"pl330"
"poly1305_neon"
"polyval_ce"
"polyval_generic"
"pwm_bl"
"pwm_rockchip"
"pwrseq_core"
"pwrseq_simple"
"qrtr"
"raid6_pq"
"regmap_spi"
"rfkill"
"rk808_regulator"
"rk818_battery"
"rk818_charger"
"rk8xx_core"
"rk8xx_i2c"
"rk_crypto"
"rockchip_dfi"
"rockchipdrm"
"rockchip_rga"
"rockchip_saradc"
"rockchip_thermal"
"rockchip_vdec"
"rtc_rk808"
"sch_fq_codel"
"sdhci"
"sdhci_of_arasan"
"sdhci_pltfm"
"serio"
"sha1_ce"
"sha256_arm64"
"sha2_ce"
"sm4"
"snd"
"snd_hrtimer"
"snd_seq"
"snd_seq_device"
"snd_seq_dummy"
"snd_timer"
"soundcore"
"spi_nor"
"spi_rockchip"
"tun"
"udp_tunnel"
"uinput"
"uio"
"uio_pdrv_genirq"
"v4l2_h264"
"v4l2_jpeg"
"v4l2_mem2mem"
"v4l2_vp9"
"vfat"
"videobuf2_common"
"videobuf2_dma_contig"
"videobuf2_dma_sg"
"videobuf2_memops"
"videobuf2_v4l2"
"videodev"
"vivaldi_fmap"
"wireguard"
"xor"
"xor_neon"
"x_tables"
"xt_conntrack"
"xt_iprange"
"xt_LOG"
"xt_nat"
"xt_pkttype"
"xt_set"
"xt_tcpudp"
"zram"
];
};
}

View File

@@ -16,7 +16,7 @@ linux_latest.override {
# DTB = true; #< this doesn't have effect, but is default
autoModules = true;
preferBuiltin = true;
preferBuiltin = false;
enableCommonConfig = true; #< enable nixpkgs config options
kernelPatches = [
@@ -73,14 +73,14 @@ linux_latest.override {
# };
# }
# {
# # necessary only if `preferBuiltin = false`
# name = "fix-module-only";
# patch = null;
# extraStructuredConfig = with lib.kernel; {
# SUN8I_DE2_CCU = lib.mkForce module;
# };
# }
{
# necessary only if `preferBuiltin = false`
name = "fix-module-only";
patch = null;
extraStructuredConfig = with lib.kernel; {
SUN8I_DE2_CCU = lib.mkForce module;
};
}
# {
# name = "upgrade-builtins-to-module";
@@ -171,82 +171,84 @@ linux_latest.override {
# MEDIA_PCI_SUPPORT = lib.mkForce no;
# };
# }
{
# i suspect that u-boot can only load a (decompressed) image up to 64 MiB in size for this platform.
# i say that because `CONFIG_DEBUG_INFO=y` seemed to break the boot,
# when it took size from 62843392B -> 71297536B
#
# see: <repo:u-boot/u-boot:include/configs/rk3399_common.h>
# - fdt_addr_r = 0x01e00000
# - fdtoverlay_addr_r = 0x01f00000
# - kernel_addr_r = 0x02080000
# - ramdisk_addr_r = 0x06000000
# - kernel_comp_addr_r = 0x08000000
# - kernel_comp_size = 0x02000000
# to avoid overlapping the ramdisk, the kernel must be smaller than 0x06000000 - 0x02080000 = 0x3f80000 = 63.5 MiB = 66584576B
# this is possibly adjustable via `/boot/ubootefi.var`? or embedding u-boot directives in extlinux.conf?
#
# largest observed bootable image: 63300096B
# smallest observed non-bootable image: 71297536B
name = "optimize-for-size";
patch = null;
extraStructuredConfig = with lib.kernel; {
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE = no;
CONFIG_CC_OPTIMIZE_FOR_SIZE = yes;
DEBUG_KERNEL = lib.mkForce no; #< TODO: something re-enabled this...
# DEBUG_FS = no;
# DEBUG_FS_ALLOW_ALL = no;
DEBUG_MISC = no;
DEBUG_INFO_NONE = yes;
DEBUG_INFO = no;
DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT = lib.mkForce no;
DEBUG_INFO_BTF = lib.mkForce no; # BPF debug symbols. rec by <https://nixos.wiki/wiki/Linux_kernel#Too_high_ram_usage>
DEBUG_LIST = lib.mkForce no;
# GPIO_VIRTUSER = no;
DYNAMIC_DEBUG = lib.mkForce no;
# PM_ADVANCED_DEBUG = lib.mkForce no;
SCHED_DEBUG = lib.mkForce no;
SLUB_DEBUG = no;
SUNRPC_DEBUG = lib.mkForce no;
# {
# # i suspect that u-boot can only load a (decompressed) image up to 64 MiB in size for this platform.
# # i say that because `CONFIG_DEBUG_INFO=y` seemed to break the boot,
# # when it took size from 62843392B -> 71297536B
# #
# # see: <repo:u-boot/u-boot:include/configs/rk3399_common.h>
# # - fdt_addr_r = 0x01e00000
# # - fdtoverlay_addr_r = 0x01f00000
# # - kernel_addr_r = 0x02080000
# # - ramdisk_addr_r = 0x06000000
# # - kernel_comp_addr_r = 0x08000000
# # - kernel_comp_size = 0x02000000
# # to avoid overlapping the ramdisk, the kernel must be smaller than 0x06000000 - 0x02080000 = 0x3f80000 = 63.5 MiB = 66584576B
# # this is possibly adjustable via `/boot/ubootefi.var`? or embedding u-boot directives in extlinux.conf?
# #
# # largest observed bootable image: 63300096B
# # smallest observed non-bootable image: 71297536B
# name = "optimize-for-size";
# patch = null;
# extraStructuredConfig = with lib.kernel; {
# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE = no;
# CONFIG_CC_OPTIMIZE_FOR_SIZE = yes;
# these particular options bloat the kernel and are almost *surely* unused.
CORESIGHT = no; #< CPU tracing
COMEDI = no; #< data acquisition devices
DAMON = lib.mkForce no; #< perf-based monitoring, to see how frequently different memory regions are accessed
DRM_AMDGPU = no;
DRM_NOUVEAU = no;
DRM_RADEON = no;
DRM_XE = no; #< intel graphics
DVB_CORE = no; #< digial video (tuners)
# FPGA = no;
INFINIBAND = lib.mkForce no; #< networking protocol
IWLWIFI = no; #< intel wireless
MEDIA_ANALOG_TV_SUPPORT = lib.mkForce no;
MEDIA_DIGITAL_TV_SUPPORT = lib.mkForce no;
MEDIA_RADIO_SUPPORT = no; # AM/FM tuners
MEDIA_SDR_SUPPORT = no; # without this, `CONFIG_MEDIA_TUNER` spontaneously re-appears...
MEDIA_TUNER = no;
# NET_VENDOR_INTEL = no; # TODO: does this impact e.g. USB-eth adapters?
SPEAKUP = no; #< text to speech
# DEBUG_KERNEL = lib.mkForce no; #< TODO: something re-enabled this...
# # DEBUG_FS = no;
# # DEBUG_FS_ALLOW_ALL = no;
# DEBUG_MISC = no;
# DEBUG_INFO_NONE = yes;
# DEBUG_INFO = no;
# DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT = lib.mkForce no;
# DEBUG_INFO_BTF = lib.mkForce no; # BPF debug symbols. rec by <https://nixos.wiki/wiki/Linux_kernel#Too_high_ram_usage>
# DEBUG_LIST = lib.mkForce no;
# # GPIO_VIRTUSER = no;
# DYNAMIC_DEBUG = lib.mkForce no;
# # PM_ADVANCED_DEBUG = lib.mkForce no;
# SCHED_DEBUG = lib.mkForce no;
# SLUB_DEBUG = no;
# SUNRPC_DEBUG = lib.mkForce no;
PCI = no;
# SCSI = no; #< USB_STORAGE depends on SCSI?...
# # these particular options bloat the kernel and are almost *surely* unused.
# CORESIGHT = no; #< CPU tracing
# COMEDI = no; #< data acquisition devices
# DAMON = lib.mkForce no; #< perf-based monitoring, to see how frequently different memory regions are accessed
# DRM_AMDGPU = no;
# DRM_NOUVEAU = no;
# DRM_RADEON = no;
# DRM_XE = no; #< intel graphics
# DVB_CORE = no; #< digial video (tuners)
# # FPGA = no;
# INFINIBAND = lib.mkForce no; #< networking protocol
# IWLWIFI = no; #< intel wireless
# MEDIA_ANALOG_TV_SUPPORT = lib.mkForce no;
# MEDIA_DIGITAL_TV_SUPPORT = lib.mkForce no;
# MEDIA_RADIO_SUPPORT = no; # AM/FM tuners
# MEDIA_SDR_SUPPORT = no; # without this, `CONFIG_MEDIA_TUNER` spontaneously re-appears...
# MEDIA_TUNER = no;
# # NET_VENDOR_INTEL = no; # TODO: does this impact e.g. USB-eth adapters?
# SPEAKUP = no; #< text to speech
# PCI = no;
# # SCSI = no; #< USB_STORAGE depends on SCSI?...
# # net stuff, disabled as much to save space as to be hardened
# DNS_RESOLVER = no;
# MPLS = no; # "MultiProtocol Label Switching"
# OPENVSWITCH = no;
# TLS = lib.mkForce no; #< TLS can be done in userspace (and more safely)
# # weird networking protocols nothing on my PCs are going to be using:
# ATM = no;
# IP_VS = no; #< weird load balancing thing for server farms
# LAPB = no;
# RDS = no; # "Reliable Datagram Sockets Protocol"
# TIPC = no; # "Transparent Inter Process Communication" (net proto)
# X25 = no;
# };
# }
# net stuff, disabled as much to save space as to be hardened
DNS_RESOLVER = no;
MPLS = no; # "MultiProtocol Label Switching"
OPENVSWITCH = no;
TLS = lib.mkForce no; #< TLS can be done in userspace (and more safely)
# weird networking protocols nothing on my PCs are going to be using:
ATM = no;
IP_VS = no; #< weird load balancing thing for server farms
LAPB = no;
RDS = no; # "Reliable Datagram Sockets Protocol"
TIPC = no; # "Transparent Inter Process Communication" (net proto)
X25 = no;
};
}
# {
# name = "reset-automodules-overrides";
# patch = null;
@@ -376,21 +378,21 @@ linux_latest.override {
# };
# }
{
# i'd like to patch some drivers, and that's easier to do when i build them for out-of-tree.
# i can't even set these to `=m`, because then nixpkgs `system.modulesTree` will complain
# about conflicting kernel modules (in tree + out-of-tree).
# so just don't build these here, and rely wholly on my out-of-tree modules.
name = "make-module-for-out-of-tree";
patch = null;
extraStructuredConfig = with lib.kernel; {
# MFD_RK8XX = no;
# MFD_RK8XX_I2C = no;
# MFD_RK8XX_SPI = no; #< necessary for MFD_RK8XX=... to apply
MFD_RK8XX = module;
MFD_RK8XX_I2C = module;
MFD_RK8XX_SPI = module;
};
}
# {
# # i'd like to patch some drivers, and that's easier to do when i build them for out-of-tree.
# # i can't even set these to `=m`, because then nixpkgs `system.modulesTree` will complain
# # about conflicting kernel modules (in tree + out-of-tree).
# # so just don't build these here, and rely wholly on my out-of-tree modules.
# name = "make-module-for-out-of-tree";
# patch = null;
# extraStructuredConfig = with lib.kernel; {
# # MFD_RK8XX = no;
# # MFD_RK8XX_I2C = no;
# # MFD_RK8XX_SPI = no; #< necessary for MFD_RK8XX=... to apply
# MFD_RK8XX = module;
# MFD_RK8XX_I2C = module;
# MFD_RK8XX_SPI = module;
# };
# }
];
}