FYI system.stateVersion doesn’t have anything to do with the version of nixpkgs you are actually pulling docs. At the moment (if you just recently installed NixOS) that value might even be “correct” in your case, but your nixpkgs input will get updated over time, while your system.stateVersion should stay the same.
What actually determines your nixpkgs version are your system channels or the inputs to your system flake, depending on what you are using.
When you run nix eval nixpkgs#<something> the nixpkgs instance referenced is determined by your configured flakerefs (nix registry list). On my flake-enabled system the nixpkgs flakeref is set to the nixpkgs instance which was used to build the system. I don’t know what happens when you are not using flakes, but if the ref is not explicitly set it falls back to nixpkgs-unstable (which AFAIK is not recommended for use as a system nixpkgs instance).
I realize this might not be relevant to the issues you were/are facing, but it might prevent a bunch of headaches in the future.
To clean up some small details, this is only true if nixpkgs.flake.setFlakeRegistry is set, rather than “flake enabled”; just setting the nix config to allow using flakes doesn’t change the registry entry.
If you are “not using flakes”, there is no flake registry, because you’re not using flakes. If by that you mean a NixOS installation that isn’t sourced from a nixpkgs retrieved through flake inputs, by default nix will use the global registry.
The nixpkgs entry in the global registry does default to the nixpkgs-unstable branch, which indeed should not be used for building NixOS, but if you’re using the global registry that’s not what you’re doing so it’s all fine.
Perhaps I mis-spoke when I said “flake-enabled”, but meant “built from a flake”.
TIL how nixpkgs.flake.setFlakeRegistry is set. Thanks!
What do you mean by “there is no registry”? Does the global registry not count or were you only concerned about the local registry?
I mentioned that, because they ran nix eval nixpkgs# and thus were potentially using the global registry.
I also noticed that you put “not using flakes” in quotes. Did you do this, because you find this description to be imprecise (if so how should such a setup be described?) or just to make clear that you are quoting someone?
Yes, that’s my point as well. Though your use of the terms is imprecise (I think?), the global registry refers specifically to the json file I linked; that’s what nix downloads to find out what your nixpkgs refers to.
When using nix eval nixpkgs#, you’re using flakes; there is no way to use the flake URI syntax without using flakes. I take issue with the term “flake-enabled”, because it’s not a well-defined term; It sounds like all you do is set --experimental-features=flakes, when you (probably?) mean NixOS built with that option set to true.
Basically, what you’re saying seems mostly correct, but it uses imprecise language and misses some nuance; I’m not sure if that’s because you don’t fully understand it or if you’re just being imprecise on accident. This might seem like splitting hairs, but I think being precise is important for people who try to learn from your comment, so I’m trying to pad out what you said with some clarifications, I’m not outright disagreeing with you or anything.
I’m not sure what you mean by “many different versions of packages”. Most of the LLVM package sets are composed of actual packages, wrapped C compilers, and stdenv’s.
Wdym by order? A lot of these packages don’t have a strict ordering, unless you’re referring to the stdenv’s and CC wrappers.
A lot of the CC wrappers & stdenvs can be ignored. The one stdenv most people will need is libcxxStdenv, and the one CC wrapper most people will end up using is clangUseLLVM.
libcxxStdenv is a basic LLVM stdenv, mainly containing clang & libc++.
clangUseLLVM is a full LLVM & clang CC environment, requires using overrideCC stdenv to inject it into a stdenv.
There’s some documentation in the nixpkgs manual. Feel free to contribute.
I had the nixpkg url set in my flake, but nix eval was using the global registry even if I pointed to the flake.lock file. I guess I needed to set nixpkgs.flake.setFlakeRegistry = true; in my flake.nix for that to work though…
I ended up removing the llvmPackages from my configuration.nix and home.nix after @RossComputerGuy recommended setting them in my project directory’s flake.nix.
This was what I was failing to accomplish with nix eval, but now using direnv and the overrideCC that @RossComputerGuy recommended (which did fix my my libcxx issues)…
IIRC, I added llvm to my flake.nix to get access to llvm-symbolizer, but it looks like llvm-symbolizer was linked to addr2line in the wrapper. Not exposing llvm-symbolizer to the path breaks my tooling since my binaries are configured in the source code to point to the cmake find_program() version…