Nix-env --list-generations is empty

I’ve done several rebuilds and no garbage collection, but ‘nix-env --list-generations’ produces no output, even as root. It’s just blank. Any idea what might be wrong?

  • EDIT: I’ve managed to get the list by using ‘sudo nix-env --list-generations --profile /nix/var/nix/profiles/system’ It looks like the profile stuff is needed if you’re running a single user system. Is that really how it works?

Generally it would help a lot if you could show exact steps to reproduce what’s happening. In this case it would help even more if you explained what you’re actually trying to achieve and why you’re using nix-env for that.

While it’s still the first thing one encounters in the Nix manual (and it will take a bit of work to move that out cleanly), nix-env is known to run users into trouble after a while. For managing your user environment (that is, keeping available packages permanently) you usually can’t go wrong with Home Manager or, if you’re fine with reconsidering a substantial part of your Linux habits, going full NixOS. (There are exceptions such as restricted environments, where `nix-env’ is the only reasonable way to leverage Nix, but you would likely know exactly what you’re doing already if that applied to you.)

Yeah, sorry. I’m running NixOS. Relatively new install. And just wanted to see the list of generations that I had after a bunch of rebuilds. I don’t use nix-env for anything and the long command gives me the info but it seems a bit odd that the shorter one doesn’t work.

In that case sudo nix-env makes perfect sense because that’s how nixos-rebuild works: it puts build results into generations of that particular profile for the root user. Likely that’s just not documented anywhere.

Feel free to add open PRs after checking the places you’d expect that information to be found and ping @NixOS/documentation-team to get a timely review. Then the next person trying to do the same thing won’t have to dig through the code. And I really wouldn’t want anyone to have to look at the current state of nixos-rebuild