Compare commits
2 Commits
b18d67a386
...
c1b048b96b
Author | SHA1 | Date |
---|---|---|
Nathan McCarty | c1b048b96b | |
Nathan McCarty | ffee83c7c5 |
|
@ -21,53 +21,42 @@ let
|
|||
nix
|
||||
nix-prefetch
|
||||
];
|
||||
in {
|
||||
# Setup hosts for gitea automation
|
||||
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 { # 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";
|
||||
};
|
||||
};
|
||||
systemd.timers."system-flake-update" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
partOf = [ "system-flake-update.service" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "Mon, 4:00";
|
||||
Unit = "system-flake-update.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";
|
||||
};
|
||||
};
|
||||
} // 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";
|
||||
}
|
||||
|
|
|
@ -4,17 +4,15 @@ set -exou pipefail
|
|||
TEMP_DIR=$(mktemp -d "repo-updater.XXXX" -p $XDG_RUNTIME_DIR)
|
||||
pushd $TEMP_DIR
|
||||
|
||||
git clone "$1" repo
|
||||
pushd repo
|
||||
git switch $2
|
||||
|
||||
./update.sh
|
||||
|
||||
git add -A
|
||||
if git commit -m "Update flake/dependencies"; then
|
||||
if git clone "$1" repo && pushd repo && git switch $2 && ./update.sh; then
|
||||
git add -A
|
||||
if git commit S -m "Update flake/dependencies"; then
|
||||
git push -u origin $2
|
||||
else
|
||||
else
|
||||
echo "No changes made"
|
||||
fi
|
||||
else
|
||||
echo "Update failed"
|
||||
fi
|
||||
|
||||
popd
|
||||
|
|
Loading…
Reference in New Issue