linux: install kernel modules to separate output

The kernel image is not functionally required at runtime in the same
output where the kernel modules are, and we can save space by removing
it.

Co-authored-by: Emily <vcs@emily.moe>
This commit is contained in:
Jared Baur 2025-07-25 16:07:58 -07:00
parent 9f9b582c69
commit f71277d66d
No known key found for this signature in database
2 changed files with 21 additions and 5 deletions

View File

@ -52,6 +52,8 @@
- `fetchtorrent`, when using the "rqbit" backend, erroneously started fetching files into a subdirectory in Nixpkgs 24.11. The original behaviour &ndash; which matches the behaviour using the "transmission" backend &ndash; has now been restored. Users reliant on the erroneous behaviour can temporarily maintain it by adding `flatten = false` to the `fetchtorrent` arguments; Nix will produce an evaluation warning for anyone using `backend = "rqbit"` without `flatten = true`.
- `linux` and all other Linux kernel packages have moved all in-tree kernel modules into a new `modules` output.
- `webfontkitgenerator` has been renamed to `webfont-bundler`, following the rename of the upstream project.
The binary name remains `webfontkitgenerator`.
The `webfontkitgenerator` package is an alias to `webfont-bundler`.

View File

@ -178,6 +178,7 @@ lib.makeOverridable (
outputs = [
"out"
"dev"
"modules"
];
})
// {
@ -336,12 +337,12 @@ lib.makeOverridable (
++ extraMakeFlags;
installFlags = [
"INSTALL_PATH=$(out)"
"INSTALL_PATH=${placeholder "out"}"
]
++ (optional isModular "INSTALL_MOD_PATH=$(out)")
++ (optional isModular "INSTALL_MOD_PATH=${placeholder "modules"}")
++ optionals buildDTBs [
"dtbs_install"
"INSTALL_DTBS_PATH=$(out)/dtbs"
"INSTALL_DTBS_PATH=${placeholder "out"}/dtbs"
];
preInstall =
@ -438,8 +439,7 @@ lib.makeOverridable (
installFlags+=("INSTALL_MOD_STRIP=1")
fi
make modules_install "''${makeFlags[@]}" "''${installFlags[@]}"
unlink $out/lib/modules/${modDirVersion}/build
rm -f $out/lib/modules/${modDirVersion}/source
unlink $modules/lib/modules/${modDirVersion}/build
mkdir -p $dev/lib/modules/${modDirVersion}/{build,source}
@ -567,6 +567,20 @@ lib.makeOverridable (
makeFlags = [
"O=$(buildRoot)"
# We have a `modules` variable in the environment for our
# split output, but the kernel Makefiles also define their
# own `modules` variable. Their definition wins, but Make
# remembers that the variable was originally from the
# environment and exports it to all the build recipes. This
# breaks the build with an “Argument list too long” error due
# to passing the huge list of every module object file in the
# environment of every process invoked by every build recipe.
#
# We use `--eval` here to undefine the inherited environment
# variable before any Makefiles are read, ensuring that the
# kernels definition creates a new, unexported variable.
"--eval=undefine modules"
]
++ commonMakeFlags;