Skip to content

Commit

Permalink
try to fix update.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
bbigras committed Jan 20, 2024
1 parent fea89af commit c68661f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/update-flakes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ jobs:
echo run git commit
git add .
git commit --amend --no-edit
echo "need_pr=1" >> "$GITHUB_ENV"
else
echo no changes
fi
- name: Create Pull Request
if: ${{ env.need_pr == 1 }}
uses: peter-evans/create-pull-request@v5
with:
branch: flake-update
Expand All @@ -49,6 +51,7 @@ jobs:
title: "flake: update"
token: ${{ secrets.PAT }}
- name: Enable Pull Request Automerge
if: ${{ env.need_pr == 1 }}
run: gh pr merge --rebase --auto --delete-branch "flake-update"
env:
GH_TOKEN: ${{ secrets.PAT }}
13 changes: 11 additions & 2 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,14 @@ set -euo pipefail
set -x

vendorHash="$(nix-instantiate ./packages.nix -A dendrite.vendorHash --eval 2>/dev/null | jq -r . || echo "missing_vendorHash")"
newvendorHash="$(nix run nixpkgs#nix-prefetch "{ sha256 }: let p=(import ./packages.nix).dendrite; in p.goModules.overrideAttrs (_: { vendorHash = sha256; })")"
sed -i "s|${vendorHash}|${newvendorHash}|" build.nix

sed -i "s|${vendorHash}|sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=|" build.nix
run_build="$(nix build 2>&1 || true)"

if [[ $run_build == *"hash mismatch in fixed-output derivation"* ]]; then
regex="got:[ ]+(sha256[^=]+=)"

if [[ $run_build =~ $regex ]]; then
sed -i "s|sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=|${BASH_REMATCH[1]}|" build.nix
fi
fi

0 comments on commit c68661f

Please sign in to comment.