Skip to content

Instantly share code, notes, and snippets.

@Panky-codes
Last active June 11, 2024 14:23
Show Gist options
  • Save Panky-codes/59a5684cccdf5f4f811782e222cac330 to your computer and use it in GitHub Desktop.
Save Panky-codes/59a5684cccdf5f4f811782e222cac330 to your computer and use it in GitHub Desktop.
Building custom kernel in NixOS
{ pkgs, ... }:
# Modified version of pkgs.linuxPackages_custom to accept kernelPatches
let
customPackage = { version, src, configfile, modDirVersion ? pkgs.lib.versions.pad 3 version, kernelPatches ? [ ], allowImportFromDerivation ? true }:
pkgs.lib.recurseIntoAttrs (pkgs.linuxPackagesFor (pkgs.linuxManualConfig {
inherit version src configfile modDirVersion kernelPatches allowImportFromDerivation;
}));
in
customPackage {
version = "6.10.0-rc3-bcache";
modDirVersion = "6.10.0-rc3";
configfile = ./config_6_10_rc3;
src = pkgs.fetchurl {
url = "https://git.kernel.org/torvalds/t/linux-6.10-rc3.tar.gz";
hash = "sha256-z5Z89iBz9YojSC3RpXlEPjqXhXCt1AIxqlK7DL9lnkg=";
};
kernelPatches = [{
name = "bcachefs";
patch = ./bcachefs.patch;
}];
}
{
...
boot.initrd.includeDefaultModules = false; #Optional if you don't want all the default modules
boot.kernelPackages = import ./custom-kernel.nix { inherit pkgs; };
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment