First pass at oracles automation

This commit is contained in:
Nathan McCarty 2023-05-13 17:24:13 -04:00
parent 5c2fa7957b
commit 2165a016e9
Signed by: thatonelutenist
SSH Key Fingerprint: SHA256:hwQEcmak9E6sdU9bXc98RHw/Xd1AhpB5HZT7ZSVJkRM
3 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,28 @@
{ config, lib, pkgs, inputs, ... }:
let
repo-updater = pkgs.writeShellScriptBin "repo-updater"
(builtins.readFile ../../scripts/gitea/update-repo.sh);
in {
# Automate updating rust utility flake
systemd.services."rust-util-update" = {
environment = {
XDG_RUNTIME_DIR = "/tmp";
HOME = "/home/nathan";
};
path = with pkgs; [
git
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.nurl
jq
curl
openssh
];
script = ''
env
{repo-updater}/bin/repo-updater gitea@git.stranger.systems:nix/Rust.git trunk
'';
serviceConfig = {
Type = "oneshot";
User = "nathan";
};
};
}

View File

@ -1,6 +1,7 @@
{ config, lib, pkgs, inputs, ... }:
{
imports = [ ./automation.nix ];
# Sops setup for this machine
sops.secrets = {
"borg-ssh-key" = {

22
scripts/gitea/update-repo.sh Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -eou 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
git push -u origin $2
else
echo "No changes made"
fi
popd
popd
rm -rf $TEMP_DIR