summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnnus <[email protected]>2025-02-15 10:15:16 +0100
committerLinnnus <[email protected]>2025-02-15 10:49:59 +0100
commitf6c352b5f259db809f999c90191f6d1cfb02f330 (patch)
tree12ebc8cc78b152eb5808b26eb6288f4ca52c2d66
parent645ec7c7a5069a246a53e46b16d99b091d6b7328 (diff)
muhammed: Add launchd service to update git repos
-rw-r--r--hosts/muhammed/configuration.nix1
-rw-r--r--hosts/muhammed/update-git-repos/default.nix23
2 files changed, 24 insertions, 0 deletions
diff --git a/hosts/muhammed/configuration.nix b/hosts/muhammed/configuration.nix
index d351ece..54fd36e 100644
--- a/hosts/muhammed/configuration.nix
+++ b/hosts/muhammed/configuration.nix
@@ -10,6 +10,7 @@
../../shared/nixos-and-darwin/common-hm-settings
./remote-builders
+ ./update-git-repos
];
# Avoid downloading the nixpkgs tarball every hour.
diff --git a/hosts/muhammed/update-git-repos/default.nix b/hosts/muhammed/update-git-repos/default.nix
new file mode 100644
index 0000000..673f86d
--- /dev/null
+++ b/hosts/muhammed/update-git-repos/default.nix
@@ -0,0 +1,23 @@
+{pkgs, ...}: {
+ launchd.agents."update-git-repos" = {
+ serviceConfig = {
+ ProgramArguments = let
+ script = pkgs.writeShellScript "update-git-repos" ''
+ printf '\x1b[1m=> Starting %s\x1b[0m\n' "$(basename "$0")"
+ find ~/Source ~/Projects -name '*.git' -print0 | while read -d $'\0' -r repo; do
+ printf '\x1b[1m=> Updating %s\x1b[0m\n' "$repo"
+ git -C "$repo" fetch --all
+ done
+ '';
+ in
+ # This *should* forward the scripts output to the universal logging system.
+ # I can't really figure it out and I kind of hate all of Apple's tooling.
+ ["/bin/sh" "-c" "${script} 2>&1 | logger -s"];
+
+ # Only run this service when network is available.
+ KeepAlive.NetworkState = true;
+
+ StartInterval = 3600; # Once an hour.
+ };
+ };
+}