kernel: use nixpkgs architecture defaults, override only the fields i care about

This commit is contained in:
2024-10-06 18:19:40 +00:00
parent 7795a3f6aa
commit d109f0faa3

View File

@@ -54,29 +54,32 @@ let
# via <repo:nixos/nixpkgs:lib/systems/platforms.nix>.
# but i want these a little more normalized, which is possible either here, or
# by assigning `boot.kernelPackages`.
#
# TODO: maybe just call `lib.platforms.elaborate`, and patch whatever i care about on top that?
elaborate = system: {
inherit system;
linux-kernel.name = "unknown"; #< i'm 90% sure this doesn't impact anything
linux-kernel.baseConfig = "defconfig";
linux-kernel.DTB = system != "x86_64-linux"; #< x86_64 doesn't even know how to compile device trees
linux-kernel.autoModules = true;
# build all features as modules where possible, especially because
# 1. some bootloaders fail on large payloads and this allows the kernel/initrd to be smaller.
# 2. building as module means i can override that module very cheaply as i develop.
linux-kernel.preferBuiltin = false;
# `target` support matrix:
# Image: aarch64:yes (nixpkgs defaule) x86_64:no
# Image.gz: aarch64:yes, if capable bootloader x86_64:no
# zImage aarch64:no x86_64:yes
# bzImage aarch64:no x86_64:yes (nixpkgs default)
# vmlinux aarch64:? x86_64:no?
# vmlinuz aarch64:? x86_64:?
# uImage aarch64:bootloader? x86_64:probably not
linux-kernel.target = if system == "x86_64-linux" then "bzImage" else "Image";
};
# elaborate = system: system;
elaborate = system: let
e = lib.systems.elaborate system;
in
{
inherit system;
linux-kernel = {
inherit (e.linux-kernel) name baseConfig target;
} // (lib.optionalAttrs (e.linux-kernel ? DTB) { inherit (e.linux-kernel) DTB; }) // {
# explicitly ignore nixpkgs' extraConfig and preferBuiltin options
autoModules = true;
# build all features as modules where possible, especially because
# 1. some bootloaders fail on large payloads and this allows the kernel/initrd to be smaller.
# 2. building as module means i can override that module very cheaply as i develop.
preferBuiltin = false;
# `target` support matrix:
# Image: aarch64:yes (nixpkgs default) x86_64:no
# Image.gz: aarch64:yes, if capable bootloader x86_64:no
# zImage aarch64:no x86_64:yes
# bzImage aarch64:no x86_64:yes (nixpkgs default)
# vmlinux aarch64:? x86_64:no?
# vmlinuz aarch64:? x86_64:?
# uImage aarch64:bootloader? x86_64:probably not
# # target = if system == "x86_64-linux" then "bzImage" else "Image";
};
};
hosts = builtins.foldl'
# XXX: i `elaborate` localSystem the same as i do `system` because otherwise nixpkgs