Move kernel config to its own role.

This commit is contained in:
Tom Alexander
2026-05-31 02:03:49 -04:00
parent 0fa170c57e
commit 246b903b2f
4 changed files with 313 additions and 64 deletions

View File

@@ -1,7 +1,6 @@
{
config,
lib,
pkgs,
...
}:
@@ -49,71 +48,13 @@
};
config = lib.mkMerge [
(lib.mkIf (!config.me.optimizations.enable) (
lib.mkMerge [
{
boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_6_18;
# boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux;
}
]
))
(lib.mkIf config.me.optimizations.enable (
lib.mkMerge [
{
boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_me;
nixpkgs.hostPlatform = {
gcc.arch = config.me.optimizations.arch;
gcc.tune = config.me.optimizations.arch;
};
nixpkgs.overlays = [
(
final: prev:
let
addConfig =
additionalConfig: pkg:
pkg.override (oldconfig: {
structuredExtraConfig = pkg.structuredExtraConfig // additionalConfig;
});
in
{
linux_me = addConfig {
# Server | No preemption - Run until the next tick. Highest throughput but can cause stutter.
# PREEMPT = lib.mkOverride 60 lib.kernel.no;
# Desktop | Preempt kernel threads only at pre-defined places that call cond_resched().
PREEMPT_VOLUNTARY = lib.mkOverride 60 lib.kernel.no;
# Low-latency desktop | Full preemption - Kernel threads can be preempted unless they hold a spinlock or are in a no-preemption section.
PREEMPT = lib.mkOverride 60 lib.kernel.yes;
# RT - All kernel code is preemptible except for a few critical sections.
# Middle ground | Real-time tasks preempt immediately like FULL, normal tasks run until the next tick.
PREEMPT_LAZY = lib.mkOverride 90 lib.kernel.no;
# Google's BBRv3 TCP congestion Control
TCP_CONG_BBR = lib.kernel.yes;
DEFAULT_BBR = lib.kernel.yes;
# Preemptive Full Tickless Kernel at 300Hz
HZ = lib.kernel.freeform "300";
HZ_300 = lib.kernel.yes;
HZ_1000 = lib.kernel.no;
} prev.linux_6_18; # or prev.linux
}
)
(final: prev: {
inherit (final.unoptimized)
assimp
binaryen
gsl
rapidjson
ffmpeg-headless
ffmpeg
pipewire
chromaprint
gtkmm
;
})
];
}
]
))