I’ve run into a bit of a weird issue that I don’t know how to deal with. Essentially, I am trying to use an Emacs package (built outside of Nix) which itself builds a standalone binary it communicates with. The details don’t really matter, but the build is calling nix-instantiate with <nixpkgs> variable and later nix-shell to get its build-time dependencies. Taking a glance at the output of the build log, I noticed that there are some quite old packages being built, which didn’t make sense to me. After some investigation I found this command to figure out what value of <nixpkgs> is being used:
which is pointing to a quite old commit. Now, my system is configured using a flake targeting nixos-unstable (not located in /etc/nixos, either), so I don’t really interact with the non-flake mechanics at all. The current version of my system is shown below:
nixos-version
23.05.20230408.d9f759f (Stoat)
Upon further investigation, the commit specified by <nixpkgs> seems to be identical to the one in the file /nix/var/nix/profiles/per-user/root/channels/nixos/svn-revision file. I’m not going to pretend I understand the usage of channels all that well, even before I started using flakes, but I did at some point imperatively update the channel the system knows:
Yet the per-user root channel is still pointing to a very old stable commit, for whatever reason. I did run sudo nix-channel --update after changing the channel from stable to nixos-unstable, but it seems to have not had any effect as far as I can tell? Could someone please explain what I should do to keep <nixpkgs> up-to-date with nixos-unstable, while being able to continue with the sudo nixos-rebuild boot --flake . usage I’ve been doing so far. Thanks!
Hi, do you mean as in adding it with nix-channel --add? I don’t know how that is meant to usually work, but interestingly I had no channels for my user, only root. I have now added nixos-unstable for my personal user and did nix-channel --update but the nix-instantiate --eval -E ‘(import <nixpkgs> {}).lib.version’ command, both with and without sudo, still results in “22.05.3441.fe76645aaf2”.
Good call about $NIX_PATH, there was several different paths there that I don’t think I even really use, so there was likely some conflict there. I’ve been messing around with some of the stuff imperatively and also using code from @amardeep who replied below you so it has totally changed, but this is what I have now after adapting the registry and path stuff from Misterio’s config:
Also, the channel was in fact named nixos and not nixpkgs before I started all of this stuff, does that really make a difference?
Oh hey, thanks very much for that. It seems to have helped. See above for what my current $NIX_PATH is now. It’s funny, I’ve actually relied on that guy’s config quite heavily in my own, but those specific settings I actually needed, I never used. Too much stuff to keep track of…
Only thing I’m not sure of now is, do I actually need the nixpkgs in nix-channel that was imperatively specified, or is it fine to remove that? I’d like to avoid any other potential conflicts if possible. That seems to be the value used at the head of the $NIX_PATH from ~/.nix-defexpr/channels, and that is now pointing to the current git commit for nixos-unstable, but I’m not sure if this will ever change unless I manually run nix-channel --update? On top of that, with the proper setup for nix-channel, the lib.version from <nixpkgs> is 23.05pre471774.fd531dee22c, which is the latest commit for nixos-unstable branch, so that is fine. However, if I remove the channel from nix-channel, then the lib.version gives me 23.05pre-git, but I can’t find a reference to that on Github and I don’t know where it is defined. Would that be the same or a different commit?