Where does nix profile get versions from?

I’m trying to test a newer version of Nix to debug an issue and when I try using nixpkgs it fails with:

 > nix profile install nixpkgs\#nix_2_18 
error: flake 'flake:nixpkgs' does not provide attribute 'packages.x86_64-linux.nix_2_18', 'legacyPackages.x86_64-linux.nix_2_18' or 'nix_2_18'
       Did you mean one of nix_2_3, nix_2_4, nix_2_5 or nix_2_6?

So I tired using nixos-unstable:

 > nix profile install nixpkgs/nixos-unstable\#nix_2_18 
error: flake 'flake:nixpkgs/nixos-unstable' does not provide attribute 'packages.x86_64-linux.nix_2_18', 'legacyPackages.x86_64-linux.nix_2_18' or 'nix_2_18'
       Did you mean one of nix_2_3, nix_2_4, nix_2_5 or nix_2_6?

But that doesn’t work either, despite nix_2_18 is clearly available in nixos-unstable:

So I don’t get what the issue is.

I’ve went through the official documentation here:
https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-profile-install

And as far as I can tell it doesn’t properly explain where it gets the source of nixpkgs. There is this:

The Nix search path is initialized from the colon-separated NIX_PATH environment variable, and is used to look up the location of Nix expressions using paths enclosed in angle brackets (i.e., <nixpkgs> ).

But if that was true I’d see at least the nix_2_14, which I already use on my system, but it can’t find that either.

When you refer to flakes without a URI, they are taken from the flake registry. nixpkgs usually refers to unstable unless you’ve explicitly changed it.

That said, the package you’re looking for is nixpkgs#nixVersion.nix_2_18, or github:NixOS/nixpkgs/nixos-unstable#nixVersion.nix_2_18 if you configured your registry to point at a different branch.

1 Like

Right, but this doesn’t work:

 > nix profile install nixpkgs\#nixVersion.nix_2_18 
error: flake 'flake:nixpkgs' does not provide attribute 'packages.x86_64-linux.nixVersion.nix_2_18', 'legacyPackages.x86_64-linux.nixVersion.nix_2_18' or 'nixVersion.nix_2_18'
       Did you mean nixVersions?

And neither does this:

 > nix profile install github:NixOS/nixpkgs/nixos-unstable\#nixVersion.nix_2_18 
error: flake 'github:NixOS/nixpkgs/nixos-unstable' does not provide attribute 'packages.x86_64-linux.nixVersion.nix_2_18', 'legacyPackages.x86_64-linux.nixVersion.nix_2_18' or 'nixVersion.nix_2_18'
       Did you mean nixVersions?

I also tried some other approaches like:

 > nix profile install -I nixpkgs=github:NixOS/nixpkgs/nixos-unstable nixpkgs\#nixVersion.nix_2_18 
error: flake 'flake:nixpkgs' does not provide attribute 'packages.x86_64-linux.nixVersion.nix_2_18', 'legacyPackages.x86_64-linux.nixVersion.nix_2_18' or 'nixVersion.nix_2_18'
       Did you mean nixVersions?

 > nix profile install -I nixpkgs=github:NixOS/nixpkgs/nixos-unstable nixpkgs\#nix.nix_2_18          
error: flake 'flake:nixpkgs' does not provide attribute 'packages.x86_64-linux.nix.nix_2_18', 'legacyPackages.x86_64-linux.nix.nix_2_18' or 'nix.nix_2_18'
       Did you mean lib?

 > nix profile install -I nixpkgs=github:NixOS/nixpkgs/nixos-unstable nixpkgs\#nix_2_18    
error: flake 'flake:nixpkgs' does not provide attribute 'packages.x86_64-linux.nix_2_18', 'legacyPackages.x86_64-linux.nix_2_18' or 'nix_2_18'
       Did you mean one of nix_2_3, nix_2_4, nix_2_5 or nix_2_6?

I really don’t understand how this is supposed to work.

Found one that worked!

nix profile install 'nixpkgs#nixVersions.nix_2_18'

It’s nixVersions not nixVersion.

Thanks for the suggestions @TLATER .

1 Like

Ah, sorry, typo on my side!

1 Like

No worries, appreciate the help.