From 9050a996666b84a9ad4e5f9bbfd481088370d009 Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 18 Feb 2024 18:07:38 +0100 Subject: [PATCH 1/2] pkgs/nixfiles: nixfiles-updated-inputs use intermediate branch for updating flake inputs --- pkgs/nixfiles/nixfiles-updated-inputs.sh | 37 +++++++++++++++++------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/pkgs/nixfiles/nixfiles-updated-inputs.sh b/pkgs/nixfiles/nixfiles-updated-inputs.sh index 282cef4..5399d0b 100755 --- a/pkgs/nixfiles/nixfiles-updated-inputs.sh +++ b/pkgs/nixfiles/nixfiles-updated-inputs.sh @@ -2,17 +2,34 @@ set -euo pipefail -NOW="$(date --utc --iso-8601=minutes)" +xgit() { + git -c "user.name=Flake Update Bot" -c "user.email=flake-update-bot@clerie.de" "$@" +} + +NOW="$(date --utc +%Y-%m-%d-%H-%M)" + +xgit status || xgit clone gitea@git.clerie.de:clerie/nixfiles.git . -git status || git clone gitea@git.clerie.de:clerie/nixfiles.git . echo "[!] Download changes" -git fetch --all -git checkout updated-inputs -git -c "user.name=Flake Update Bot" -c "user.email=flake-update-bot@clerie.de" merge -s ort -X theirs origin/master -m "Update from master ${NOW}" -echo "[!] Update inputs" -nix flake update +xgit fetch --all + +echo "[!] Chechout remote master" +xgit checkout origin/master + +UPDATE_BRANCH="update-inputs-${NOW}" +echo "[!] Create branch ${UPDATE_BRANCH}" +xgit checkout -b "${UPDATE_BRANCH}" + +echo "[!] Update nixpkgs" +nix flake lock --update-input nixpkgs + echo "[!] Commit changes" git add flake.lock -git -c "user.name=Flake Update Bot" -c "user.email=flake-update-bot@clerie.de" commit -m "Flake update ${NOW}" || true -echo "[!] Publish" -git push origin updated-inputs +xgit commit -m "Update nixpkgs ${NOW}" || true + +echo "[!] Merge ${UPDATE_BRANCH} into updated-inputs" +xgit checkout updated-inputs +xgit merge -s ort -X theirs "${UPDATE_BRANCH}" -m "Update from ${UPDATE_BRANCH}" + +echo "[!] Publish updated-inputs" +xgit push origin updated-inputs From 704aba254d2e3c9dc1b04c91dc0cd581a75bcba9 Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 18 Feb 2024 18:49:29 +0100 Subject: [PATCH 2/2] pkgs/nixfiles: nixfiles-updated-inputs push update branch --- pkgs/nixfiles/nixfiles-updated-inputs.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/nixfiles/nixfiles-updated-inputs.sh b/pkgs/nixfiles/nixfiles-updated-inputs.sh index 5399d0b..2749766 100755 --- a/pkgs/nixfiles/nixfiles-updated-inputs.sh +++ b/pkgs/nixfiles/nixfiles-updated-inputs.sh @@ -24,9 +24,12 @@ echo "[!] Update nixpkgs" nix flake lock --update-input nixpkgs echo "[!] Commit changes" -git add flake.lock +xgit add flake.lock xgit commit -m "Update nixpkgs ${NOW}" || true +echo "[!] Publish ${UPDATE_BRANCH}" +xgit push --set-upstream origin "${UPDATE_BRANCH}" + echo "[!] Merge ${UPDATE_BRANCH} into updated-inputs" xgit checkout updated-inputs xgit merge -s ort -X theirs "${UPDATE_BRANCH}" -m "Update from ${UPDATE_BRANCH}"