{ config, lib, pkgs, inputs, ... }: let repo-updater = pkgs.writeShellScriptBin "repo-updater" (builtins.readFile ../../scripts/gitea/update-repo.sh); environment = { XDG_RUNTIME_DIR = "/tmp"; HOME = "/home/nathan"; NIX_PATH = "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels"; XDG_CONFIG_DIRS = "/home/nathan/.nix-profile/etc/xdg:/etc/profiles/per-user/nathan/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg"; XDG_CONFIG_HOME = "/home/nathan/.config"; }; path = with pkgs; [ git inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.nurl jq curl openssh bash nix nix-prefetch ]; 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."update-flake-${name}" = { wantedBy = [ "timers.target" ]; partOf = [ "update-flake-${name}.service" ]; timerConfig = { OnCalendar = schedule; Unit = "update-flake-${name}.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"; }) ]