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-i2c"
"rk8xx-spi" "rk8xx-spi"
# these can surely be reduced: # these were found to be loaded after the initrd, and at least one is needed.
# "8250_dw" # TODO: reduce this!
# "adc_keys" "8250_dw"
# "aes_ce_blk" "adc_keys"
# "af_alg" "aes_ce_blk"
# "algif_hash" "af_packet"
# "algif_skcipher" "analogix_dp"
# "analogix_dp" "atkbd"
# "atkbd" "autofs4"
# "autofs4" "blake2b_generic"
# "blake2b_generic" "bluetooth"
# AVOID INCLUDING brcmfmac IN INITRD, ELSE WIFI FIRMWARE WILL FAIL TO LOAD # AVOID INCLUDING brcmfmac IN INITRD, ELSE WIFI FIRMWARE WILL FAIL TO LOAD
# "bluetooth"
# "bnep"
# "brcmfmac" # "brcmfmac"
# "brcmutil" # "brcmfmac_wcc"
# "btbcm" "brcmutil"
# "btqca" "btbcm"
# "btrfs" "btqca"
# "btsdio" "btrfs"
# "cec" "btsdio"
# "cfg80211" "cec"
# "chacha_neon" "cfg80211"
# "clk_rk808" "chacha_neon"
# "cmdlinepart" "clk_rk808"
# "coresight" "coresight"
# "coresight_cpu_debug" "coresight_cpu_debug"
# "coresight_etm4x" "coresight_etm4x"
# "cpufreq_ondemand" "cpufreq_ondemand"
# "cqhci" "cqhci"
# "crc16" "crc16"
# "crc32c_generic" "crc32c_generic"
# "crct10dif_ce" "crct10dif_ce"
# "crypto_engine" "crypto_engine"
# "dax" "drm_display_helper"
# "dm_mod" "drm_dma_helper"
# "drm_display_helper" "dw_hdmi"
# "drm_dma_helper" "dw_mipi_dsi"
# "drm_shmem_helper" "dw_mmc"
# "dw_hdmi" "dw_mmc_pltfm"
# "dw_mipi_dsi" "dw_mmc_rockchip"
# "dw_mmc" "dw_wdt"
# "dw_mmc_pltfm" "ecc"
# "dw_mmc_rockchip" "ecdh_generic"
# "dw_wdt" "efi_pstore"
# "ecc" "evdev"
# "ecdh_generic" "fan53555"
# "efi_pstore" "fat"
# "evdev" "ff_memless"
# "fan53555" "fixed"
# "fat" "fuse"
# "ff_memless" "gf128mul"
# "fixed" "ghash_ce"
# "fuse" "goodix_ts"
# "gf128mul" "governor_simpleondemand"
# "ghash_ce" "gpio_keys"
# "goodix_ts" "gpio_rockchip"
# "governor_simpleondemand" "gpio_vibra"
# "gpio_keys" "gpu_sched"
# "gpio_rockchip" "hantro_vpu"
# "gpio_vibra" "hci_uart"
# "gpu_sched" "i2c_mux"
# "hantro_vpu" "i2c_rk3x"
# "hci_uart" "industrialio"
# "i2c_mux" "industrialio_triggered_buffer"
# "i2c_rk3x" "inv_mpu6050"
# "industrialio" "inv_mpu6050_i2c"
# "industrialio_triggered_buffer" "inv_mpu6050_spi"
# "inv_mpu6050" "inv_sensors_timestamp"
# "inv_mpu6050_i2c" "io_domain"
# "inv_mpu6050_spi" "ip6t_rpfilter"
# "inv_sensors_timestamp" "ip6_udp_tunnel"
# "io_domain" "ip_set"
# "ip6_udp_tunnel" "ip_set_hash_ipport"
# "ip6t_rpfilter" "ip_tables"
# "ip_set" "ipt_rpfilter"
# "ip_set_hash_ipport" "joydev"
# "ip_tables" "kfifo_buf"
# "ipt_rpfilter" "led_class"
# "joydev" "led_class_multicolor"
# "kfifo_buf" "leds_gpio"
# "led_class" "leds_group_multicolor"
# "led_class_multicolor" "libchacha"
# "leds_gpio" "libchacha20poly1305"
# "leds_group_multicolor" "libcrc32c"
# "libchacha" "libcurve25519_generic"
# "libchacha20poly1305" "libdes"
# "libcrc32c" "libps2"
# "libcurve25519_generic" "loop"
# "libdes" "mc"
# "libps2" "md5"
# "loop" "mmc_block"
# "mc" "mmc_core"
# "md5" "mousedev"
# "mmc_block" "mtd"
# "mmc_core" "nf_conntrack"
# "mousedev" "nf_defrag_ipv4"
# "mtd" "nf_defrag_ipv6"
# "nf_conntrack" "nf_log_syslog"
# "nf_defrag_ipv4" "nf_nat"
# "nf_defrag_ipv6" "nfnetlink"
# "nf_log_syslog" "nf_tables"
# "nf_tables" "nft_chain_nat"
# "nfnetlink" "nft_compat"
# "nft_compat" "nls_cp437"
# "nls_cp437" "nls_iso8859_1"
# "nls_iso8859_1" "nvmem_rockchip_efuse"
# "nvmem_rockchip_efuse" "ofpart"
# "ofpart" "panel_himax_hx8394"
# "panel_himax_hx8394" "panfrost"
# "panfrost" "phy_rockchip_emmc"
# "phy_rockchip_emmc" "pinctrl_rockchip"
# "pinctrl_rockchip" "pl330"
# "pl330" "poly1305_neon"
# "poly1305_neon" "polyval_ce"
# "polyval_ce" "polyval_generic"
# "polyval_generic" "pwm_bl"
# "pwm_bl" "pwm_rockchip"
# "pwm_rockchip" "pwrseq_core"
# "pwrseq_core" "pwrseq_simple"
# "pwrseq_simple" "qrtr"
# "qrtr" "raid6_pq"
# "raid6_pq" "regmap_spi"
# "regmap_spi" "rfkill"
# "rfkill" "rk808_regulator"
# "rk808_regulator" "rk818_battery"
# "rk8xx_core" "rk818_charger"
# "rk8xx_i2c" "rk8xx_core"
# "rk_crypto" "rk8xx_i2c"
# "rockchip_dfi" "rk_crypto"
# "rockchip_rga" "rockchip_dfi"
# "rockchip_saradc" "rockchipdrm"
# "rockchip_thermal" "rockchip_rga"
# "rockchip_vdec" "rockchip_saradc"
# "rockchipdrm" "rockchip_thermal"
# "rtc_rk808" "rockchip_vdec"
# "sch_fq_codel" "rtc_rk808"
# "sdhci" "sch_fq_codel"
# "sdhci_of_arasan" "sdhci"
# "sdhci_pltfm" "sdhci_of_arasan"
# "serio" "sdhci_pltfm"
# "sha1_ce" "serio"
# "sha256_arm64" "sha1_ce"
# "sha2_ce" "sha256_arm64"
# "sm4" "sha2_ce"
# "snd" "sm4"
# "snd_hrtimer" "snd"
# "snd_seq" "snd_hrtimer"
# "snd_seq_device" "snd_seq"
# "snd_seq_dummy" "snd_seq_device"
# "snd_timer" "snd_seq_dummy"
# "soundcore" "snd_timer"
# "spi_nor" "soundcore"
# "spi_rockchip" "spi_nor"
# "udp_tunnel" "spi_rockchip"
# "uio" "tun"
# "uio_pdrv_genirq" "udp_tunnel"
# "v4l2_h264" "uinput"
# "v4l2_jpeg" "uio"
# "v4l2_mem2mem" "uio_pdrv_genirq"
# "v4l2_vp9" "v4l2_h264"
# "vfat" "v4l2_jpeg"
# "videobuf2_common" "v4l2_mem2mem"
# "videobuf2_dma_contig" "v4l2_vp9"
# "videobuf2_dma_sg" "vfat"
# "videobuf2_memops" "videobuf2_common"
# "videobuf2_v4l2" "videobuf2_dma_contig"
# "videodev" "videobuf2_dma_sg"
# "vivaldi_fmap" "videobuf2_memops"
# "wireguard" "videobuf2_v4l2"
# "x_tables" "videodev"
# "xor" "vivaldi_fmap"
# "xor_neon" "wireguard"
# "xt_LOG" "xor"
# "xt_conntrack" "xor_neon"
# "xt_pkttype" "x_tables"
# "xt_set" "xt_conntrack"
# "xt_tcpudp" "xt_iprange"
# "zram" "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 # DTB = true; #< this doesn't have effect, but is default
autoModules = true; autoModules = true;
preferBuiltin = true; preferBuiltin = false;
enableCommonConfig = true; #< enable nixpkgs config options enableCommonConfig = true; #< enable nixpkgs config options
kernelPatches = [ kernelPatches = [
@@ -73,14 +73,14 @@ linux_latest.override {
# }; # };
# } # }
# { {
# # necessary only if `preferBuiltin = false` # necessary only if `preferBuiltin = false`
# name = "fix-module-only"; name = "fix-module-only";
# patch = null; patch = null;
# extraStructuredConfig = with lib.kernel; { extraStructuredConfig = with lib.kernel; {
# SUN8I_DE2_CCU = lib.mkForce module; SUN8I_DE2_CCU = lib.mkForce module;
# }; };
# } }
# { # {
# name = "upgrade-builtins-to-module"; # name = "upgrade-builtins-to-module";
@@ -171,82 +171,84 @@ linux_latest.override {
# MEDIA_PCI_SUPPORT = lib.mkForce no; # 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; # # i suspect that u-boot can only load a (decompressed) image up to 64 MiB in size for this platform.
# DEBUG_FS_ALLOW_ALL = no; # # i say that because `CONFIG_DEBUG_INFO=y` seemed to break the boot,
DEBUG_MISC = no; # # when it took size from 62843392B -> 71297536B
DEBUG_INFO_NONE = yes; # #
DEBUG_INFO = no; # # see: <repo:u-boot/u-boot:include/configs/rk3399_common.h>
DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT = lib.mkForce no; # # - fdt_addr_r = 0x01e00000
DEBUG_INFO_BTF = lib.mkForce no; # BPF debug symbols. rec by <https://nixos.wiki/wiki/Linux_kernel#Too_high_ram_usage> # # - fdtoverlay_addr_r = 0x01f00000
DEBUG_LIST = lib.mkForce no; # # - kernel_addr_r = 0x02080000
# GPIO_VIRTUSER = no; # # - ramdisk_addr_r = 0x06000000
DYNAMIC_DEBUG = lib.mkForce no; # # - kernel_comp_addr_r = 0x08000000
# PM_ADVANCED_DEBUG = lib.mkForce no; # # - kernel_comp_size = 0x02000000
SCHED_DEBUG = lib.mkForce no; # # to avoid overlapping the ramdisk, the kernel must be smaller than 0x06000000 - 0x02080000 = 0x3f80000 = 63.5 MiB = 66584576B
SLUB_DEBUG = no; # # this is possibly adjustable via `/boot/ubootefi.var`? or embedding u-boot directives in extlinux.conf?
SUNRPC_DEBUG = lib.mkForce no; # #
# # 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. # DEBUG_KERNEL = lib.mkForce no; #< TODO: something re-enabled this...
CORESIGHT = no; #< CPU tracing # # DEBUG_FS = no;
COMEDI = no; #< data acquisition devices # # DEBUG_FS_ALLOW_ALL = no;
DAMON = lib.mkForce no; #< perf-based monitoring, to see how frequently different memory regions are accessed # DEBUG_MISC = no;
DRM_AMDGPU = no; # DEBUG_INFO_NONE = yes;
DRM_NOUVEAU = no; # DEBUG_INFO = no;
DRM_RADEON = no; # DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT = lib.mkForce no;
DRM_XE = no; #< intel graphics # DEBUG_INFO_BTF = lib.mkForce no; # BPF debug symbols. rec by <https://nixos.wiki/wiki/Linux_kernel#Too_high_ram_usage>
DVB_CORE = no; #< digial video (tuners) # DEBUG_LIST = lib.mkForce no;
# FPGA = no; # # GPIO_VIRTUSER = no;
INFINIBAND = lib.mkForce no; #< networking protocol # DYNAMIC_DEBUG = lib.mkForce no;
IWLWIFI = no; #< intel wireless # # PM_ADVANCED_DEBUG = lib.mkForce no;
MEDIA_ANALOG_TV_SUPPORT = lib.mkForce no; # SCHED_DEBUG = lib.mkForce no;
MEDIA_DIGITAL_TV_SUPPORT = lib.mkForce no; # SLUB_DEBUG = no;
MEDIA_RADIO_SUPPORT = no; # AM/FM tuners # SUNRPC_DEBUG = lib.mkForce no;
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; # # these particular options bloat the kernel and are almost *surely* unused.
# SCSI = no; #< USB_STORAGE depends on SCSI?... # 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"; # name = "reset-automodules-overrides";
# patch = null; # 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'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 # # i can't even set these to `=m`, because then nixpkgs `system.modulesTree` will complain
# about conflicting kernel modules (in tree + out-of-tree). # # 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. # # so just don't build these here, and rely wholly on my out-of-tree modules.
name = "make-module-for-out-of-tree"; # name = "make-module-for-out-of-tree";
patch = null; # patch = null;
extraStructuredConfig = with lib.kernel; { # extraStructuredConfig = with lib.kernel; {
# MFD_RK8XX = no; # # MFD_RK8XX = no;
# MFD_RK8XX_I2C = no; # # MFD_RK8XX_I2C = no;
# MFD_RK8XX_SPI = no; #< necessary for MFD_RK8XX=... to apply # # MFD_RK8XX_SPI = no; #< necessary for MFD_RK8XX=... to apply
MFD_RK8XX = module; # MFD_RK8XX = module;
MFD_RK8XX_I2C = module; # MFD_RK8XX_I2C = module;
MFD_RK8XX_SPI = module; # MFD_RK8XX_SPI = module;
}; # };
} # }
]; ];
} }