How do I find a file in the nix store which I have fetchurled in the past?
Here is my situation. I have a specialfile which I downloaded from unreliable.com, but unreliable.com has gone offline. Now I want to save a copy of specialfile. I know specialfile is in my /nix/store because derivations which depend on specialfile still succeed. I aquired specialfile like this:
toString on the resulting derivation will give you the path. Assuming specialfile is already in your store you should be able to do something like this:
▶ nix repl
Welcome to Nix 2.7.0. Type :? for help.
nix-repl> builtins.fetchurl {
url = "https://unreliable.com/specialfile";
sha256 = "sha256-EVA7G7f+eP0q3u0oGcD9RpbPIUn83ClrMddCIbyTVK4=";
}
"/nix/store/<hash>-specialfile"
nix-repl>
Thanks for the answers but I still can’t find the specialfile. I can see from /nix/store/npxpdhbi6azk4vcmjdqv9mnp8nx2ikz9-specialfile.drv that the "out" path for specialfile should be /nix/store/jlbm1nwc29ibpkxvxm4m2igqj73xh6kn-specialfile, but there is no such file.
I didn’t mention that I never did the fetchurl on this machine; actually someone else did the fetchurl and stored it in a central private cache and I’ve always gotten it from the cache. Does that make a difference? I think it shouldn’t?
What was going on here is that the specialfile was in the cache. I had never actually downloaded specialfile from the cache, I had only downloaded cached derivations which depended on specialfile.