Pinning nixpkgs for nixos-rebuild

For a few revisions of nixos-unstable now, there have been newly-introduced bugs in xfce that are quite annoying. I want to use an older version of nixpkgs, but still be able to make changes to my configuration.nix (yes, I am not using home manager atm). I found this issue: Pinning nixpkgs in configuration.nix? · Issue #62832 · NixOS/nixpkgs · GitHub, wrote an expression for my desired revision of nixpkgs, and then tried most of the ways that were mentioned to get my setup to work, without success.

My expected outcome does not seem to me so crazy: Build nixos as if the relevant channel was at the specified commit. Is there no standard way to do this?

3 Likes

I believe the issue in xfce would be xfce, mate: preferences not shown in menu · Issue #82571 · NixOS/nixpkgs · GitHub.
Fix for that should be coming soon.

Ok, so executing
nix-channel --add https://github.com/NixOS/nixpkgs/archive/hash-of-the-commit-to-pin.tar.gz nixos
(sudo nix-channel, if you save your channels as root), as buried in this reply Pinning nixpkgs in configuration.nix? · Issue #62832 · NixOS/nixpkgs · GitHub finally did the trick for me.

I would prefer not to have to pin the channel in this way, since I would like new nix-shell derivations to start out on the newest unstable, even if the system itself has to lag behind a bit.

Essentially, I would prefer for the system itself to be more like a nix-shell environment. Usually tracking unstable, but pinnable to a commit if something is broken, then updated if new features are wanted and the original reason for pinning is resolved.

you can so specify the path with -I

  sudo nixos-rebuild -I nixpkgs=/some/path/to/nixpkgs switch

This will allow you target a nixpkgs checkout, helpful you’re developing locally, otherwise you could pin the version of pkgs to a checkout of your desire

2 Likes

Also see this discussion: Pinning nixpkgs in configuration.nix? · Issue #62832 · NixOS/nixpkgs · GitHub for a fully contained configuration.nix.

1 Like

Ahh, ok, this finally worked for me. The important thing is to pass the url to the tar archive (e.g. https://github.com/nixos/nixpkgs/archive/8130f3c1c2b.tar.gz). I previously tried passing a nix expression where I specified nixpkgs with builtins.fetchTarball. That didn’t work.