Why does the same Nix expression behave differently in different `nix-shell` calls?

There seems to be a caching mechanism in place. This may something very basic, but somehow I missed it thus far, so any extra info would be welcome.

The issues: I use the following one-liner to import a Nix expression from my repo:

nix-shell  -v \
  -E 'import (builtins.fetchurl "https://raw.githubusercontent.com/toraritte/shell.nixes/main/baseline_config.nix")' \
  --argstr "nixpkgs_commit" "3ad7b8a7e8c2da367d661df6c3742168c53913fa"

After adding some tools and waiting for GitHub to update the “raw” link, I ran the same command, but the new packages are not present. Downloaded it with curl, and that works:

curl https://raw.githubusercontent.com/toraritte/shell.nixes/main/baseline_config.nix -O
nix-shell -v baseline_config.nix

Calling the raw GitHub links pinned to commits

Using this Bash function to make it easier on the eyes:

getShell () { \
   nix-shell  -v \
  -E "import (builtins.fetchurl \
      \"https://raw.githubusercontent.com/toraritte/shell.nixes/$1/baseline_config.nix\")" \
  --argstr "nixpkgs_commit" "832bdf74072489b8da042f9769a0a2fac9b579c7"; \
}

curlShell () { \
  curl "https://raw.githubusercontent.com/toraritte/shell.nixes/$1/baseline_config.nix" -O; \
  nix-shell -v baseline_config.nix; \
}
  • Using the commit without the new packages:

    getShell "a348b5782b11779d18dca0aa23e3ad8294b607b9"
    

    results in a shell with the same behaviour as

    curlShell "a348b5782b11779d18dca0aa23e3ad8294b607b9"
    
  • Using the commit with the new packages (8c8fc4096f9265d56a86df460dccb5397abf874d) will also be identical in behaviour.


By the time finished typing this, getShell "main" (the first code block I had issue with) also has the new packages now, so there is definitely a caching mechanism that I managed to miss so far…

Would you link some documentation to this? I’m curious how long the cache lives or when is it triggered? I presume the raw link with main was the same with every call so that’s easy to understand why Nix would cache it.

tarball-tll.