Apt is designed so you don't need a list of every (non-transitive) package.
For a different installation with the same applications, you need only the small list of top-level packages in the dependency chain -- the packages that are not dependencies. Most users find this much-smaller list to be easier to manage.
One fairly easy way to accomplish this using 22.10 Desktop as an example:
- List the set of packages apt-marked manual.
sudo apt-mark listmanual > listmanual
- List the set of packages that are included with a stock install of Ubuntu. Awk is used to remove additional fields and preserve only the package names.
wget -O - http://releases.ubuntu.com/releases/22.10/ubuntu-22.10-desktop-amd64.manifest | awk '{print $1}' > manifest
- Remove any packages in #2 from #1.
comm -2 -3 manual manifest
- Review your
comm
output, which should be short enough to be manageable. Do not include random libraries, dependencies, metapackages, no-longer-used applications, old mistakes, and other obvious unwanteds.
Your final reviewed package list are the packages you want to install on the newly-installed system.