Nix copying a store-path into the store

This snippet should no longer be required on versions of Nix >= 2.24.14. Copying of path type inputs like these have been fixed as of create cache entry for paths already in the nix store by Mic92 · Pull Request #12911 · NixOS/nix · GitHub, and I can’t replicate any kind of issue with them even on the latest Nix versions

…but it seems similar behavior has appeared recently elsewhere:

The main idea behind it is the indirection. As opposed to passing a store path directly, using something like the Flake registry or a symlink allows for the same NIX_PATH to immediately being resolving to the new paths (when otherwise services, shells, etc. would need to restart to get the new NIX_PATH with new paths applied). The Flake registry is just one way to do this

It’s been recommended against to use /etc as a location for symlinks, though, as it’s a bit more stateful. So if you want to add your system’s Nixpkgs to your NIX_PATH without using Flakes (and the bugs associated with them), this snippet would probably be a bit better