nix
nix copied to clipboard
typing "nix-env -i" should not try to install every single package
I did this by accident and was alarmed to find 5000 packages starting to download onto my machine, which seems wasteful from a bandwidth and a disk space perspective, given that few people would actually want every package on their machine.
A better approach would be to exit with the error message "Please specify a package to install", optionally with instructions on how to download everything.
I've come to like this feature; nix-env -q queries everything, nix-env -u updates everything, and so logically nix-env -i should install everything.
On the other hand, it would be nice to have a "5000 packages will be installed, 10 GB will be downloaded, ... Continue? [y/n]" prompt like apt-get, as currently that information scrolls offscreen very quickly.
That would also be acceptable..
I recently hit an issue due to this behavior. In #3227 I was calling nix-env -i $(nix-build something)
, in the event of a build failure, nix-env will nicely start to install everything. In most cases it just leads to a difficult to understand error, in some cases it uses a lot of space / bandwidth.
I marked this as stale due to inactivity. → More info
I think this should still be addressed!
Copying subscribers from duplicate #1334: @copumpkin @Diti @ericsagnes @shlevy @vcunat
I marked this as stale due to inactivity. → More info
This should still be addressed.
Just got into this situation by following the instructions in the official docs available after installation.
6.2 Ad-Hoc Package Management
Packages come from the NixOS channel. You typically upgrade a package by updating to the latest version of the NixOS channel:
nix-channel --update nixos and then running nix-env -i again
I run update and then nix-env -i.
Not stale.
just made this mistake, surprised it hasnt been fixed in so long
Here's the culprit: https://github.com/NixOS/nix/blob/b7e712f9fd3b35e7b75180fcfbe90dce6c9b06a4/src/nix-env/nix-env.cc#L325-L327
If no positional parameter is specified, args
stays empty. Unfortunately, simply replacing that by a throw Error("No package specified")
would not do the trick, as installing/querying things from specified sources would have to be taken into account. For example you can do nix-env -if ./stuff.nix
to install all derivations from that file.
@RoboBurned in the meantime the issue with the manual suggesting to use nix-env -i
to beginners will be addressed by implementing https://github.com/NixOS/nix/issues/7769.
Almost 10 years later, and I did this mistake as well.