How to use nixos-unstable for some packages only?


I’m using flakes and I’d like to use the new stable channel 23.11 but for some packages, I’d like to use the latest versions (unstable). I always get an error when trying to rebuild.

I’m able to set nixpkgs-unstable.url and then I have

  outputs = { self, nixpkgs, nixpkgs-unstable, ... }@attrs: {
    nixosConfigurations.fnord = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = attrs;
      modules = [ ./configuration.nix ];

How in my configuration.nix can I use nixpkgs-unstable?

I’d like to be able to do something like

systemPackages = with pkgs; [
  # ...

Thank you!

1 Like

I’m probably the last person who should be answering, cus I barely know what I’m doing, but I did manage to get that working recently with an overlay:

1 Like

Another example using flakes is here (found via the ZFS Root for Nixos pages):

1 Like

I also use an overlay called “unstable” like this:

(final: prev: {
  unstable = import nixpkgs-unstable {
    system = prev.system;

when installing packages it’s then possible to use pkgs.unstable.rustc like in your example.