Also, why not simply configure
system.autoUpgrade.flake = "github:YourUser/yourRepo";
system.autoUpgrade.enable = true;
Or, for more complicated setups, running a git comand via either cron or a systemd timer as recommended here Automatic rebuild on every push to master · Issue #5 · zupo/nix · GitHub
{
systemd.timers.git-updater = {
wantedBy = [ "timers.target" ];
# Wait 60 seconds after the service finished before starting it again
# This should prevent the service being started again too early if an update is in progress
timerConfig.OnUnitInactiveSec = 60;
};
systemd.services.git-updater = {
# I'm not entirely sure why this would be needed
serviceConfig.Type = "oneshot";
script = ''
# Update script here
'';
};
}