How to cross compile the raspberrypi kernel on nixos? (aarch64)

I cloned the raspberrypi kernel repo, ran this command:
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig
then I got this error:

scripts/Kconfig.include:40: C compiler 'aarch64-linux-gnu-gcc' not found
make[2]: *** [scripts/kconfig/Makefile:102: bcm2711_defconfig] Error 1
make[1]: *** [/home/spiderunderurbed/linux/Makefile:686: bcm2711_defconfig] Error 2
make: *** [Makefile:224: __sub-make] Error 2
[ble: exit 2]

I tried this shell:

{
  pkgs ? import <nixpkgs> {}
}:

pkgs.mkShell {
  buildInputs = [
    pkgs.pkgsCross.aarch64-multiplatform.buildPackages.gcc
    pkgs.git
    pkgs.bison
    pkgs.flex
    pkgs.ncurses
    pkgs.openssl
  ];
}

Whats the correct way/shell to compile the raspberrypi kernel, like what packages am I missing or am i doing something wrong

Where are you compiling from?

As having a shell.nix, I would assume that you’re trying to compile from a different device.
In that case, have a look at the cross compiling doc.
e.g:

with import <nixpkgs> {
  crossSystem = {
    config = "aarch64-unknown-linux-gnu";
  };
};

mkShell {
  buildInputs = [ zlib ]; # your dependencies here
}

Or if you want it “system-wide”, add the following to your configuration.nix:

{
    boot = {
      binfmt.emulatedSystems = [
        "aarch64-linux"
      ];
    };
}