BaseOS and AppStream are the default repositories.
There is no reason to add that configuration as they are already provided by the rocky-repos package in /etc/yum.repos.d/Rocky-BaseOS.repo and Rocky-AppStream.repo. It sounds like you have made changes to the default configuration and you’re now having issues and it is not clear what changes you have made. You are also not providing any information as to the issues you’re actually having.
See below. They are already provided. They are not labeled “BaseOS” and “AppStream”, they are simply “baseos” and “appstream”. You’ll find these configurations are exactly as you have shown, except for the names themselves.
The /etc/yum.repos.d/*.repo files are mostly from (RPM) packages and tagged as “config” files.
That affects what DNF does when you update those packages. If config file has been modified,
then update does not repalec it, but adds corresponding *.rpmnew file that has new content.
Then it is up to the user to merge changes from *.repo.rpmnew into *.repo.
You can run rpm -V rocky-repos to see whether some files from that package are modified or missing.
You can run dnf reinstall rocky-repos to reinstall the missing files, but as said the modified files stay.
I would probably create a temporary repo definition:
Then remove the modified Rocky*.repo files, once more dnf reinstall rocky-repos
and finally remove the temporary: rm /etc/yum.repos.d/dl.rockylinux.org*.repo
The DNF does show the source of each package. The rightmost column in dnf list is repoid (and ‘@’ indicates that packet is installed). We can list installed packages that are not from baseos or appstream:
dnf list installed | grep -Ev "@appstream|@baseos"
and shrink the list to unique values:
dnf list installed | grep -Ev "@appstream|@baseos" | while read F B G ; do echo $G ; done | sort -u
Some of those are from initial installation, but some can be repoids that you had defined. As I said, it depends on what you had.