nixos/kernel.nix: ensure same kernel is used

Originally, changes to the kernel don't propagate to the other
derivation within the same package set. This commit allows for the
changes in the kernel to be propagated.

A distinct example is setting `boot.kernel.randstructSeed` to a non-zero
length string which would result in building 2 kernels, one with the
correct seed and the other with the zero length seed. Then, when using
an out-of-tree kernel driver, it would be built with the zero length
seed which differs from the non-zero length seed used to boot,
contradicting the purpose of the `boot.kernel.randstructSeed`.
This commit is contained in:
Edmund Wu 2020-05-14 22:08:26 -04:00
parent 1ac4c06c08
commit 78f915a002
No known key found for this signature in database
GPG key ID: 0D62311F6343DE1A

View file

@ -37,12 +37,10 @@ in
boot.kernelPackages = mkOption {
default = pkgs.linuxPackages;
type = types.unspecified // { merge = mergeEqualOption; };
apply = kernelPackages: kernelPackages.extend (self: super: {
kernel = super.kernel.override {
inherit randstructSeed;
kernelPatches = super.kernel.kernelPatches ++ kernelPatches;
features = lib.recursiveUpdate super.kernel.features features;
};
apply = kernelPackages: pkgs.linuxPackagesFor (kernelPackages.kernel.override {
inherit randstructSeed;
kernelPatches = kernelPackages.kernel.kernelPatches ++ kernelPatches;
features = lib.recursiveUpdate kernelPackages.kernel.features features;
});
# We don't want to evaluate all of linuxPackages for the manual
# - some of it might not even evaluate correctly.