Moving from nix-env to configuration.nix

Hello there, brand new to NixOS. (Just yesterday)
As with a lot of users, I happened across NixOS package search, and used the nix-env method to add almost all my packages.

My question is, how could one go about “migrating” those previously added packages to the configuration file instead.

Ideally without duplicating the packages, though perhaps not, and preferably without losing any app changes/settings that have been made.

If none of that is doable, I suppose I just pull a package list and begin the drudgery.
Any suggestion of how to pull a list of packages I have added the “wrong” way?

[Edit:]
I marked the solution, it turns out I hadn’t added as much as I believed, and removing them manually and adding them back in to the configuration.nix file was a very viable option.
Thank you.

nix-env -q is probably what you’re looking for
nix-store -q might also be useful

Note that nix-env -q will list package names, and for writing a configuration.nix you’ll want package attribute paths, and they’re sometimes but not generally the same.

That’s a great starting point, thank you for the help rhendric.