Does calling nix-env -i without providing a package name attempt to install every available package? I accidentally did this and I got over 50,000 “installing ” messages. Eventually the call threw an error because one of the packages had an unfree license. But would nix-env have actually installed all these packages had that not been the case?
Is this a bug, because I can’t think why this would be a feature. Also is there anything I need to do to clean up the mess caused by this beyond calling nix-collect-garbage? It is also doesn’t seem like any of the packages listed before the one that caused the unfree license error got installed either, so I’m not sure what’s up with that.
To check if nix-env actually created any garbage collection roots, I think you’d just use nix-env -q. Anything not listed there should be cleaned up by a garbage-collect. You can also check the roots directly, advice from the wiki: https://nixos.wiki/wiki/Storage_optimization#Garbage_collection
Yes, it does, but if the call failed then the packages haven’t been installed to your profile yet, so you can just run nix-collect-garbage to remove them all from the Nix Store again.
Basically, the default case for nix-env -i is to traverse all packages of all channels and find those that match the name you gave it. This is super inefficient, and has the side-effect that you can not only install multiple packages at once, but also that you install all packages at once, as an empty search matches every package.
You should thus always use nix-env -iA nixpkgs.$name (replacing $name with the name of the package you want to install) as this is fast and unambiguous. I’m not sure if fixing the behviour of nix-env -i was ever considered. If you know, you know, and all the documentation points towards using nix-env -iA (or the excrutiatingly long nix-env --install --attr.
The new CLI will make this less of an issue, nix profile install will fail if you don’t provide it with an input, but that’s still considered experimental.