From 45538c767c7ff0b23e68fb9887772038f7d8ea44 Mon Sep 17 00:00:00 2001 From: emily Date: Thu, 16 May 2024 22:21:01 +0200 Subject: [PATCH] more opsies --- modules/update-nixfiles/default.nix | 4 +++- pkgs/update-nixfiles/update-nixfiles.sh | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/modules/update-nixfiles/default.nix b/modules/update-nixfiles/default.nix index b5ed47b..2638d7d 100644 --- a/modules/update-nixfiles/default.nix +++ b/modules/update-nixfiles/default.nix @@ -42,11 +42,13 @@ in { }; }; programs.ssh = { + enable = true; addKeysToAgent = "yes"; - matchBlocks."git.bsd.gay".indentityFile = cfg.privateKey; + matchBlocks."git.bsd.gay".identityFile = cfg.privateKey; }; services.ssh-agent.enable = true; }; + nix.settings.accept-flake-config = true; programs.ssh = { knownHosts."git.bsd.gay".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHd48YPVXBWVdQwVAF16Ihs7FNTPmD1kMUnOfQttc1bA"; }; diff --git a/pkgs/update-nixfiles/update-nixfiles.sh b/pkgs/update-nixfiles/update-nixfiles.sh index fff20d9..888a237 100644 --- a/pkgs/update-nixfiles/update-nixfiles.sh +++ b/pkgs/update-nixfiles/update-nixfiles.sh @@ -8,7 +8,7 @@ JOBSET_URL="${HYDRA_URL}/jobset/nixfiles/update-inputs" ROOT="$(mktemp -d)" gitin () { - git -C "${ROOT}" "$@" + git -C "${ROOT}/nixfiles" "$@" } merge_theirs () { @@ -43,14 +43,14 @@ wait_for_hydra () { local counter counter=0 git_rev="$(gitin rev-parse update-inputs)" - while [[ $counter -le 30 ]]; do - hydra_rev="$(curl -s -L -H "Accept: application/json" "${JOBSET_URL}/latest-eval" 2> /dev/null | jq -r .flake | sed -E "s/.+&rev=(.*)/\1/g")" + while true; do + hydra_rev="$(curl -s -L -H "Accept: application/json" "${JOBSET_URL}/latest-eval" | jq -r .flake | sed -E "s/.+&rev=(.*)/\1/g")" + echo "${hydra_rev}" if [[ "${git_rev}" == "${hydra_rev}" ]]; then echo "Hydra got new commit" break fi sleep 30 - ((counter++)) done if [[ $counter -ge 30 ]]; then echo "Hydra no workey" @@ -58,13 +58,18 @@ wait_for_hydra () { fi } -git clone git@git.bsd.gay:snaki/nixfiles.git "${ROOT}" +ssh-agent -a "${ROOT}/ssh-agent" +SSH_AUTH_SOCK="${ROOT}/ssh-agent" +export SSH_AUTH_SOCK +ssh-add "/run/secrets/services/update-nixfiles/privateKey" + +git clone git@git.bsd.gay:snaki/nixfiles.git "${ROOT}/nixfiles" gitin fetch --all gitin checkout origin/main gitin checkout -b "${BRANCH}" -pushd "${ROOT}" +pushd "${ROOT}/nixfiles" nix flake update --commit-lock-file popd @@ -92,4 +97,6 @@ echo "Merging ${BRANCH} into main" gitin checkout main gitin merge --ff-only "${BRANCH}" gitin push origin main + +pkill ssh-agent echo "Update successful"