List Installed Packages Alternative (nixos-option)

I need to list all installed packages on a system, where the configuration.nix has been corrupted.

I see that I can do that with nixos-option, but this command is not installed.

Any way to do it another way?:wink:

If your configuration is corrupt, nixos-option can’t help you.

It works by reading the config.

It doesn’t see the actual state of the system. It just sees your configuration file.

nix run nixpkgs#nix-tree

What does this command do?:wink:

ok, it runs nix-tree without it needing to be installed, but I think what I need is a way to generate a list of all the packages I have installed, so that I can put that into an old backup of configuration.nix, so that I don’t lose any packages when I rebuild.

The best would be a top level package list that was in configuration.nix, but I guess that’s not possible.

I also had some other settings that were in that file, but I would have to recreate those manually.