Nix-shell -p running an old version?

I’m trying to run a package (yarn-berry) that I find via https://search.nixos.org/
If I look at the source there, it reports version 4.0.1.

On my mac, when I run nix-shell -p yarn-berry I get version 4.0.1

But on linux, no matter what I do, I always get 3.2.0

This is what I tried so far:

> nix-collect-garbage -d
...
> nix-channel --update
unpacking channels...
>nix-channel --list
nixpkgs-unstable https://nixos.org/channels/nixpkgs-unstable
> nix-shell -p yarn-berry

In this new shell:

[nix-shell:~]$ type yarn
yarn is /nix/store/w5kij9d9hnflmch1ic7zkh2gmi4dnfgd-yarn-berry/bin/yarn

[nix-shell:~]$ yarn --version
3.2.0

Why do I get version 3.2.0??

sudo nix-channel --list

returns nothing.
without sudo: nixpkgs-unstable https://nixos.org/channels/nixpkgs-unstable

What does

nix-instantiate --eval -E '(import <nixpkgs> { }).lib.trivial.revisionWithDefault ""'

say?

> nix-instantiate --eval -E '(import <nixpkgs> { }).lib.trivial.revisionWithDefault ""'
""

What’s the content of

/nix/var/nix/profiles/per-user/$USER/channels/nixpkgs/.git-revision

Also just noticed your channel is called nixpkgs-unstable. nix-shell will use the channel called nixpkgs. If you had a nixpkgs channel before, it might still be around. Check /nix/var/nix/profiles/per-user/$USER/channels/ and /nix/var/nix/profiles/per-user/root/channels/.

➜ pwd
/nix/var/nix/profiles/per-user/thomas/channels
➜ ll
lrwxrwxrwx - root  1 Jan  1970 manifest.nix -> /nix/store/k85k972pjsc96yc6bgd7326z6wqfwc5k-env-manifest.nix
lrwxrwxrwx - root  1 Jan  1970 nixpkgs-unstable -> /nix/store/qxk3dqalh4l234sncrrdrjr3mdzlddsb-nixpkgs-unstable/nixpkgs-unstable

root is empty.

➜ pwd
/nix/var/nix/profiles/per-user/thomas/channels/nixpkgs-unstable
➜ cat .git-revision
09ec6a0881e1a36c29d67497693a67a16f4da573⏎

as you can see /nix/var/nix/profiles/per-user/$USER/channels/nixpkgs/.git-revision does not exist

Again, check /nix/var/nix/profiles/per-user/root/channels/.

the root folder is completely empty

You’re going to have to walk your $NIX_PATH and look for nixpkgs sub-directories. Nix chooses the first one I believe.