I need to run a script that sets up some user specific stuff, which needs to succeed when I rebuild my system or else the user environment is rendered “unusable” for the sake of argument.
system.userActivationScripts seems perfectly suited for this, however the task I need to execute includes cloning a git repository (my homemanager config and dotfiles), which would break the constraint given in the description of the config option which requires scripts to be idempotent and fast,
Here is the thing:
A failed clone should also fail the rebuild since the repo is required for the system to work.
I have seen others use systemd user services that run at startup to accomplish this, but this won’t fail the rebuild if the script fails. It will also make the script run on each system startup which will waste performance when it is needed elsewhere, internet might not be available at that time and, since the script is dependent only on the system config (and the state of the external server, but lets ignore that for now) it only has to run whenever the system config changes and not on each boot.
Should I use userActivationScripts for this? Should I use a service that runs on startup? Is there another way to make scripts run when the system config is being rebuilt?