Help with using stable and unstable packages from flakes

After attempting to update to 24.05 now that my exams are over and I have a little bit of free time, I am experiencing the same problem as described here: Hyprland not starting after upgrading to NixOS 24.05,
but I do not understand how to implement the solution, which is to “use the unstable kernelPackages and the unstable nvidia driver”.

I have gotten my system to work with Flakes and have added both the stable Nix Packages (23.11 for now, since that version works for me, but I’ll try 24.05 again after this is all fixed) and the Unstable one. I do not know how to make use of them in my configuration to alleviate the problem.

I have decided to make this new thread because I remembered that resurrecting solved threads is impolite on the internet.

Hey @ejb, I don’t use Hyprland, so I won’t be able to help you there. I hope I can help you use the kernel packages from the nixos-unstable release channel. [0]

You mentioned you are already using Flakes; great. Roughly, this is how you can set the release channels to, in this case, use the kernel packages from unstable:

flake.nix:

{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-24.05";
    nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
  };

  ...

  let
    system = "x86_64-linux";

    unstablePkgs = import "${nixpkgs-unstable}" {
      inherit system;
      config = {
        allowUnfree = true;
        permittedInsecurePackages = [ "openssl-1.1.1w" ]; # Sublime 4
      };
    };
  in
  {
    nixosConfigurations = {
      YOUR_HOSTNAME = nixpkgs.lib.nixosSystem {
        inherit system unstablePkgs;
        specialArgs = { inherit inputs system; };
        modules = [

          ...

          {
            boot.kernelPackages = unstablePkgs.linuxPackages_latest;
          }
        ];
      };
    };
  };
}

My implementation here.


[0]: You can, of course, define whatever release channels you want this way.
[1]: If you were to define boot.kernelPackages = on a downstream module, you need to pass unstablePkgs in the specialArgs attribute instead.

Thank you for your help. This is an interesting way to do this, and it is a little more comprehensible than the method for enabling unstable packages on the Wiki. The main thing I was stuck on was realising that linuxPackages was inside pkgs (or in this case, unstablePkgs).