How to upgrade imperatively-installed nix-env packages with "only" 16G ram?

If I imperatively install packages with nix-env -iA packagename and then update my channels, how do I update the installed packages?

nix-env --upgrade tries to evaluate all of nixpkgs and gets earlyoom-killed after using all (16G) my ram and all (12G) my swap.

I can't get the attr names of installed packages with nix-env --query --installed --attr-path because --attr-path only works with --available, not --installed.

Is keeping track of the attr names separately (not really using nix-env to manage installed packages) the only way?

(Please no "use flakes" or "use declarative nix-env -r with a buildEnv overlay that's the list of packages you want". I understand that these are alternatives. I'm trying to determine if there's any way to use the imperative nix-env -i mechanism and still have automatic updates.)

4 points · 2 comments · view on lemmy.world

2 Comments

crocswithsocks@lemmy.world · 1 pts · 330d (1 reply)

Can you add more swap? Create a temporary swap file and then update? It might take a while to complete but it should work.

chkno@lemmy.ml · 2 pts · 330d

I'm looking for something that can run unobtrusively in the background as an automatic update. I don't have the cgroups wizardry skill to make swapping out many gigabytes non-disruptive to a normal desktop experience.