I want to sync git repos between my laptop and my desktop computer, but I only want to clone new git repos if they don’t exists on one of the computers. Further data sync is done with git pull/push as usual.
For example, if I have the following configuration
Desktop computer:
dev/
** projectA/
** projectB/
** projectC/
Laptop:
dev/
** projectA/
** projectB/
I would like that my next nixos-rebuild switch on the laptop makes a clone of projectC inside the dev/ directory
Of course, nixos configuration is synched with a git repo between the two computers.
I was thinking about using home manager opt-home.activation option Appendix A. Configuration Options but there’s maybe a better way to do this.
If you need an example, I do something like this in my flake here. I check if a directory doesn’t exist and clone the repo if needed.
I have two config options that I created — dotfilesRepo which is the SSH URL and dotfilesPath. I have to convert the SSH URL to HTTPS in order to clone without an SSH key, so it would probably be simpler if I just started with an HTTPS URL instead.
When using the activation script, I tried to make sure I was adhering to the “dry run” guarantee, but otherwise it’s fairly straightforward.