Automate update of java flake
This commit is contained in:
parent
470a48a1ea
commit
61ac3881d4
|
@ -21,53 +21,48 @@ let
|
||||||
nix
|
nix
|
||||||
nix-prefetch
|
nix-prefetch
|
||||||
];
|
];
|
||||||
in {
|
update-flake = { name, repo, schedule, branch ? "trunk" }: {
|
||||||
# Setup hosts for gitea automation
|
systemd.services."update-flake-${name}" = {
|
||||||
networking.hosts = { "100.99.69.14" = [ "git.stranger.systems" ]; };
|
inherit environment;
|
||||||
|
inherit path;
|
||||||
# Automate updating the system flake
|
script = ''
|
||||||
systemd.services."system-flake-update" = {
|
env
|
||||||
inherit environment;
|
${repo-updater}/bin/repo-updater ${repo} ${branch}
|
||||||
inherit path;
|
'';
|
||||||
script = ''
|
serviceConfig = {
|
||||||
env
|
Type = "oneshot";
|
||||||
${repo-updater}/bin/repo-updater gitea@git.stranger.systems:nix/System.git trunk
|
User = "nathan";
|
||||||
'';
|
Group = "users";
|
||||||
serviceConfig = {
|
};
|
||||||
Type = "oneshot";
|
|
||||||
User = "nathan";
|
|
||||||
Group = "users";
|
|
||||||
};
|
};
|
||||||
};
|
systemd.timers."update-flake-${name}" = {
|
||||||
systemd.timers."system-flake-update" = {
|
wantedBy = [ "timers.target" ];
|
||||||
wantedBy = [ "timers.target" ];
|
partOf = [ "update-flake-${name}.service" ];
|
||||||
partOf = [ "system-flake-update.service" ];
|
timerConfig = {
|
||||||
timerConfig = {
|
OnCalendar = schedule;
|
||||||
OnCalendar = "Mon, 4:00";
|
Unit = "update-flake-${name}.service";
|
||||||
Unit = "system-flake-update.service";
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Automate updating rust utility flake
|
in lib.mkMerge [
|
||||||
systemd.services."rust-util-update" = {
|
{ # Setup hosts for gitea automation
|
||||||
inherit environment;
|
networking.hosts = { "100.99.69.14" = [ "git.stranger.systems" ]; };
|
||||||
inherit path;
|
}
|
||||||
script = ''
|
(update-flake {
|
||||||
env
|
name = "system";
|
||||||
${repo-updater}/bin/repo-updater gitea@git.stranger.systems:nix/Rust.git trunk
|
repo = "gitea@git.stranger.systems:nix/System.git";
|
||||||
'';
|
schedule = "Mon, 4:00";
|
||||||
serviceConfig = {
|
})
|
||||||
Type = "oneshot";
|
(update-flake {
|
||||||
User = "nathan";
|
name = "rust-util";
|
||||||
Group = "users";
|
repo = "gitea@git.stranger.systems:nix/Rust.git";
|
||||||
};
|
schedule = "Mon, 8:00";
|
||||||
};
|
})
|
||||||
systemd.timers."rust-util-update" = {
|
(update-flake {
|
||||||
wantedBy = [ "timers.target" ];
|
name = "java";
|
||||||
partOf = [ "rust-util-update.service" ];
|
repo = "gitea@git.stranger.systems:nix/java.git";
|
||||||
timerConfig = {
|
branch = "master";
|
||||||
OnCalendar = "Mon, 8:00";
|
schedule = "6:00";
|
||||||
Unit = "rust-util-update.service";
|
})
|
||||||
};
|
]
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,17 +4,15 @@ set -exou pipefail
|
||||||
TEMP_DIR=$(mktemp -d "repo-updater.XXXX" -p $XDG_RUNTIME_DIR)
|
TEMP_DIR=$(mktemp -d "repo-updater.XXXX" -p $XDG_RUNTIME_DIR)
|
||||||
pushd $TEMP_DIR
|
pushd $TEMP_DIR
|
||||||
|
|
||||||
git clone "$1" repo
|
if git clone "$1" repo && pushd repo && git switch $2 && ./update.sh; then
|
||||||
pushd repo
|
git add -A
|
||||||
git switch $2
|
if git commit -S -m "Update flake/dependencies"; then
|
||||||
|
git push -u origin $2
|
||||||
./update.sh
|
else
|
||||||
|
echo "No changes made"
|
||||||
git add -A
|
fi
|
||||||
if git commit -m "Update flake/dependencies"; then
|
|
||||||
git push -u origin $2
|
|
||||||
else
|
else
|
||||||
echo "No changes made"
|
echo "Update failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
|
Loading…
Reference in New Issue