From 8f64710826442e3bfd2e2e221051dfb47491bd09 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Mon, 15 May 2023 22:36:03 -0400 Subject: [PATCH] Automate update of java flake --- machines/oracles/automation.nix | 86 +++++++++++++++------------------ 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/machines/oracles/automation.nix b/machines/oracles/automation.nix index 854b3e9..df0bd88 100644 --- a/machines/oracles/automation.nix +++ b/machines/oracles/automation.nix @@ -21,53 +21,47 @@ let nix nix-prefetch ]; -in { - # Setup hosts for gitea automation - networking.hosts = { "100.99.69.14" = [ "git.stranger.systems" ]; }; - - # Automate updating the system flake - systemd.services."system-flake-update" = { - inherit environment; - inherit path; - script = '' - env - ${repo-updater}/bin/repo-updater gitea@git.stranger.systems:nix/System.git trunk - ''; - serviceConfig = { - Type = "oneshot"; - User = "nathan"; - Group = "users"; + update-flake = { name, repo, schedule, branch ? "trunk" }: { + systemd.services."update-flake-${name}" = { + inherit environment; + inherit path; + script = '' + env + ${repo-updater}/bin/repo-updater ${repo} ${branch} + ''; + serviceConfig = { + Type = "oneshot"; + User = "nathan"; + Group = "users"; + }; }; - }; - systemd.timers."system-flake-update" = { - wantedBy = [ "timers.target" ]; - partOf = [ "system-flake-update.service" ]; - timerConfig = { - OnCalendar = "Mon, 4:00"; - Unit = "system-flake-update.service"; + systemd.timers."update-flake-${name}" = { + wantedBy = [ "timers.target" ]; + partOf = [ "update-flake-${name}.service" ]; + timerConfig = { + OnCalendar = schedule; + Unit = "update-flake-${name}.service"; + }; }; }; - # Automate updating rust utility flake - systemd.services."rust-util-update" = { - inherit environment; - inherit path; - script = '' - env - ${repo-updater}/bin/repo-updater gitea@git.stranger.systems:nix/Rust.git trunk - ''; - serviceConfig = { - Type = "oneshot"; - User = "nathan"; - Group = "users"; - }; - }; - systemd.timers."rust-util-update" = { - wantedBy = [ "timers.target" ]; - partOf = [ "rust-util-update.service" ]; - timerConfig = { - OnCalendar = "Mon, 8:00"; - Unit = "rust-util-update.service"; - }; - }; -} +in lib.mkMerge [ + { # Setup hosts for gitea automation + networking.hosts = { "100.99.69.14" = [ "git.stranger.systems" ]; }; + } + (update-flake { + name = "system"; + repo = "gitea@git.stranger.systems:nix/System.git"; + schedule = "Mon, 4:00"; + }) + (update-flake { + name = "rust-util"; + repo = "gitea@git.stranger.systems:nix/Rust.git"; + schedule = "Mon, 8:00"; + }) + (update-flake { + name = "java"; + repo = "gitea@git.stranger.systems:nix/java.git"; + schedule = "6:00"; + }) +]