A lot of kernels

Suddenly, when i try to rebuild switch, nix populates my boot/kernels with a bunch of junk. I tried deleting, but it doesn’t help.

when i try to use boot.kernelPackages = pkgs.linuxPackages_latest; there is an issue with nvidia…

my boot config

 boot.loader.grub = {
      enable = true;
      device = "nodev";
      efiSupport = true;
      useOSProber = true;
  };

  boot.loader.efi.canTouchEfiVariables = true;

What is “bunch of junk”? What is “an issue with nvidia”?
Please be specific and detailed.

1 Like

“bunch of junk” →


(i didn’t get why there are different versions)

“issue with nvidia” →


(i can provide all logs if needed)

The reason for all the kernels in /boot/kernels is because every live nixos generation needs its kernel there so that you can boot any of those generations. sudo nix-env -p /nix/var/nix/profiles/system --list-generations to see how many generations you have. You can sudo nix-env -p /nix/var/nix/profiles/system --delete-generations .... to delete some, and then nixos-rebuild again to repopulate the boot menu and erase obsolete kernels from /boot/kernels. Though, rather than nix-env --delete-generations, sudo nix-collect-garbage --delete-older-than will actually delete obsolete files from /nix/store as well.

No idea why nvidia is failing to build, sorry.

2 Likes

ooh, it makes so much sense…
Thank you!

I used udo nix-collect-garbage --delete-older-than 30d, as you suggested.
At the end i needed to clean up unused kernels by myself, but after this it builds as it should.
Many thanks again.

(I didn’t test with oot.kernelPackages = pkgs.linuxPackages_latest; yet, but I will later)