1
0

pkgs/nixfiles: rename nixfiles-updated-inputs to clerie-update-nixfiles

This commit is contained in:
2024-03-17 16:14:54 +01:00
parent 23d05a3e5d
commit 7a4177f360
6 changed files with 11 additions and 11 deletions

View File

@@ -0,0 +1,12 @@
{ pkgs, ... }:
pkgs.writeShellApplication {
name = "clerie-update-nixfiles";
text = builtins.readFile ./clerie-update-nixfiles.sh;
runtimeInputs = with pkgs; [
git
nix
openssh
];
}

View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail
xgit() {
git -c "user.name=Flake Update Bot" -c "user.email=flake-update-bot@clerie.de" -c "core.pager=cat" "$@"
}
NOW="$(date --utc +%Y-%m-%d-%H-%M)"
xgit status || xgit clone gitea@git.clerie.de:clerie/nixfiles.git .
echo "[!] Download changes"
xgit fetch --all
echo "[!] Chechout remote master"
xgit checkout origin/master
UPDATE_BRANCH="updated-inputs-${NOW}"
echo "[!] Create branch ${UPDATE_BRANCH}"
xgit checkout -b "${UPDATE_BRANCH}"
echo "[!] Update nixpkgs"
nix flake lock --update-input nixpkgs
echo "[!] Commit changes"
xgit add flake.lock
xgit commit -m "Update nixpkgs ${NOW}" || true
xgit diff --name-status origin/updated-inputs "${UPDATE_BRANCH}"
echo "[!] biep"
if xgit diff --quiet origin/updated-inputs "${UPDATE_BRANCH}"
then
echo "[!] Nothing changed, removing branch"
xgit branch -D "${UPDATE_BRANCH}"
exit 0
fi
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}"
echo "[!] Publish updated-inputs"
xgit push origin updated-inputs