You can get the list of installed modules using zef list --installed. Note you probably want to ignore the share/perl6 repo, as the CORE module included in it is specific to each version of rakudo.
see: https://github.com/ugexe/zef#list-from
list [*@from]
List known available distributions
$ zef --installed list
===> Found via /home/nickl/.rakubrew/moar-master/install/share/perl6/site
CSV::Parser:ver<0.1.2>:auth<github:tony-o>
Zef:auth<github:ugexe>
===> Found via /home/nickl/.rakubrew/moar-master/install/share/perl6
CORE:ver<6.c>:auth<perl>
Alternatively you can use the following one-liner to get a list:
$ raku -e 'say $*REPO.repo-chain.grep(CompUnit::Repository::Installation).map(*.installed.Slip).grep(*.defined).map({ CompUnit::Repository::Distribution.new($_).Str }).join(" ")'
Text::Table::Simple:ver<0.0.7>:auth<github:ugexe>:api<> CSV::Parser:ver<0.1.2>:auth<github:tony-o>:api<> CORE:ver<6.d>:auth<perl>:api<>
# $*REPO.repo-chain.grep(CompUnit::Repository::Installation) # Get only repos for installed raku modules
# .map(*.installed.Slip) # Get a list of installed modules for this repo, and Slip it into the outer singular results list
# .grep(*.defined) # Some repos will have had no modules, so remove these undefined entries
# .map({ CompUnit::Repository::Distribution.new($_).Str }) # Use CompUnit::Repository::Distribution to get at the normalized identifier
# .join(" ") # Join the results together
Once you have chosen a way to create a list of what needs to be installed you can just pass that list to zef (although your shell may require you to quote names passed in explicitly on the command line)