I am trying to compile a custom Linux kernel for use in NixOS. My main question is what’s the easiest and quickest way to do this. Since I am relying on an outdated upstream and want to tightly control the compilation, I don’t want to use the kernels that nixpkgs brings.
I was once told that I should use pkgs.linuxManualConfig
to generate the kernel in Nix for use in a NixOS configuration, but this function seems generally broken, even compiling the vanilla 5.14 kernel without any config
pkgs.linuxManualConfig rec {
version = "5.14";
src = fetchTarball {
url = "https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-${version}.tar.xz";
sha256 = "sha256:15c91flxhankd62xwv02azjxy4hqll4s3jsl5kq8vbhjrz57lcl0";
};
configfile = ./linux-config-empty;
stdenv = pkgs.gcc10Stdenv; # doesn't seem to set the GCC used for compilation
};
fails with errors like
subcmd-util.h:58:31: error: pointer 'ptr' may be used after 'realloc' [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wuse-after-free-Werror=use-after-free8;;]
58 | ret = realloc(ptr, 1);