Automate mirrorlist generation with Pacman hook:

Create a file /etc/pacman.d/hooks/mirrorupgrade.hook

$ sudo mkdir /etc/pacman.d/hooks
$ sudo nano /etc/pacman.d/hooks/mirrorupgrade.hook

Add the following lines:

[Trigger]
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist

[Action]
Description = Updating pacman-mirrorlist with reflector and removing pacnew...
When = PostTransaction
Depends = reflector
Exec = /bin/sh -c "reflector --country 'United States'--latest 10 --sort rate --protocol https --save /etc/pacman.d/mirrorlist"

Save and close the file. 

reflector-pacman-hook.txt
# Revision: 2023.07.07 -- by eznix (https://sourceforge.net/projects/ezarch/)
# (GNU/General Public License version 3.0)
