From acd9d8d70f04c181b7bcb09dd6074afba9b693ae Mon Sep 17 00:00:00 2001 From: mayor Date: Sat, 14 Feb 2026 18:15:36 -0800 Subject: [PATCH 1/2] Skip already-cached packages in CI build-and-cache job --- .gitea/workflows/ci.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index fa26c9a..f0b4ae6 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -56,9 +56,20 @@ jobs: ) FAILED=() + SKIPPED=() for pkg in "${PACKAGES[@]}"; do echo "::group::Building $pkg" - # Capture build output, extract store path (last line starting with /nix/store/) + + # Check if package is already cached by evaluating its store path and checking the remote + OUT_PATH=$(nix build ".#$pkg" --no-link --print-out-paths --dry-run 2>/dev/null | grep '^/nix/store/' | tail -1) + if [ -n "$OUT_PATH" ] && ssh -i ~/.ssh/cache_key ${{ secrets.CACHE_USER }}@${{ secrets.CACHE_HOST }} \ + "nix path-info '$OUT_PATH' >/dev/null 2>&1"; then + echo "⏭ $pkg already cached ($OUT_PATH), skipping" + SKIPPED+=("$pkg") + echo "::endgroup::" + continue + fi + # --cores 2 limits parallel jobs to reduce RAM pressure on john-endesktop if BUILD_OUTPUT=$(nix build ".#$pkg" --no-link --print-out-paths --cores 2 2>&1); then OUT_PATH=$(echo "$BUILD_OUTPUT" | grep '^/nix/store/' | tail -1) @@ -84,6 +95,10 @@ jobs: echo "::endgroup::" done + if [ ${#SKIPPED[@]} -gt 0 ]; then + echo "Skipped (already cached): ${SKIPPED[*]}" + fi + if [ ${#FAILED[@]} -gt 0 ]; then echo "::error::Failed packages: ${FAILED[*]}" exit 1 -- 2.49.1 From cd7439b132ba62e8eef08261fe5b7dca5e810739 Mon Sep 17 00:00:00 2001 From: mayor Date: Sat, 14 Feb 2026 18:25:03 -0800 Subject: [PATCH 2/2] Use nix eval for cache path detection instead of --dry-run --- .gitea/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index f0b4ae6..35f6bee 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: echo "::group::Building $pkg" # Check if package is already cached by evaluating its store path and checking the remote - OUT_PATH=$(nix build ".#$pkg" --no-link --print-out-paths --dry-run 2>/dev/null | grep '^/nix/store/' | tail -1) + OUT_PATH=$(nix eval ".#$pkg.outPath" --raw 2>/dev/null) if [ -n "$OUT_PATH" ] && ssh -i ~/.ssh/cache_key ${{ secrets.CACHE_USER }}@${{ secrets.CACHE_HOST }} \ "nix path-info '$OUT_PATH' >/dev/null 2>&1"; then echo "⏭ $pkg already cached ($OUT_PATH), skipping" -- 2.49.1