Alright, another try, this time I am almost there. I just decided to grab the exact commit I need from the remote repo.
{
boot.kernelPackages =
let
linux_pkg = { fetchgit, buildLinux, ... } @ args:
buildLinux (args // rec {
version = "5.16.9";
modDirVersion = version;
src = fetchgit
{
url = "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/";
rev = "91fc147";
sha256 = "Dz+CpecLcVU/jA00gCnOenDhL8yYzMxM58uCXcTtzj0=";
};
kernelPatches = [ ];
extraMeta.branch = "5.16";
} // (args.argsOverride or { }));
linux_5-16-9 = pkgs.callPackage linux_pkg { };
in
pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_5-16-9);
}
But now the build itself fails. Which is another problem entirely and I will open a new thread for this one I guess. But getting the right sources works now. Even though fetchgit did not want to fetch my local source tree for whatever reason…