NixOS took that particular aspect too far that I don't think it would become mainstream, especially in desktop environments. But I do agree that package management itself makes sense to do this. requirements.txt/packages.json/etc worked out for most environments, and it wouldn't require much scripting.
Linux
pacman -Qqe > pkgs.txt
and pacman -Syu < pkgs.txt
Take a look at configuration management systems like Puppet or Ansible. There are many ways to have a pre-defined, repeatable system configuration in a text file.
Configs certainly change faster than systems, I have to adatp it to hw and tasks every tima. So, pacman -S base-devel
If something like Ansible is too much, you could list the packages as a bash array in a file
pkgs=(
vim
bash-completion
...
)
Source the file
source pkgs.txt
Then install them
dnf install ${pkgs[@]}
This expands to dnf install vim bash-completion ...
As for listing the installed packages,
dnf repoquery --userinstalled --queryformat '%{name}\n'
The list includes all packages not installed as dependencies, so it's not quite perfect but might be close enough to what you need.
The array expansion workaround should work for other package managers too, as long as they take the list of packages as whitespace-separated arguments.