How many channels do you have configured?
On my macOS machine, with a single
nix-env -qa hello takes approximately 30 seconds and a maximum RSS of 1.1GiB.
On my Linode running NixOS with 2GB RAM and 2 channels configured (
nix-env -qa hello runs out of memory after 13 seconds and 1.7GiB maximum RSS.
I’m not actually sure why it requires such a high memory ceiling. I expect it’s holding onto the full package attribute set, forcing all of the thunks in turn. Perhaps we should try something like constructing a list of all the values, and then popping each value off the list in turn before evaluating the derivation, such that once it’s calculated the
name there’s nothing pointing at the derivation anymore and thus it can be collected. This would still produce a lot of GC churn, but it should reduce the maximum memory usage.
Although to be honest what we really should do is have hydra precalculate the entire list of
name = attribute-path for every package that
nix-env -q would search, and then have
nix-env just check that. It can fall back to its current behavior for any channel that doesn’t include the list. The downside here is Hydra would have to calculate that list separately for each platform, otherwise packages that bail out with
asserts on some platforms would not show up properly.