From 6c0a2682ee22eb60e8a122f82c2e8bfe220da871 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 11 Jun 2025 12:04:54 +0300 Subject: [PATCH] ci: find, build & cache packages missing in cachix Thanks Diniamo --- .github/workflows/build.yml | 39 +++++++++++++++++++++++++------------ .github/workflows/nix.yml | 4 ++++ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78c8235..effeaf7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,20 +8,35 @@ on: required: false jobs: - build: + find-uncached: + runs-on: ubuntu-latest + outputs: + uncached: ${{ steps.get-packages.outputs.packages }} + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + + - name: Find packages missing in the cache + id: get-packages + run: | + set -euo pipefail + + packages='[]' + while read -r package; do + path="$(nix eval --raw ".#$package" 2>/dev/null)" + if ! nix path-info --store https://nyx.cachix.org "$path" &>/dev/null; then + echo "Building $package" + packages="$(echo -n "$packages" | jq --arg package "$package" --compact-output '. + [$package]')" + fi + done < <(nix flake show --json 2>/dev/null | jq --raw-output '.packages."x86_64-linux" | keys_unsorted | map("packages.x86_64-linux.\(.)") | .[]') + + echo -n "packages=$packages" >> "$GITHUB_OUTPUT" + build-uncached: + needs: packages strategy: matrix: - package: - - ai-robots-txt - - alejandra-custom - - ani-cli-git - - foot-git - - fuzzel-git - - headscale-ui - - mastodon-bird-ui - - zsh-stripped - + package: ${{ fromJSON(needs.find_uncached.outputs.uncached) }} uses: ./.github/workflows/nix.yml with: - command: nix build -L .#${{ matrix.package }} -v + command: nix build "github:notashelf/nyxexprs/${{ github.ref }}#${{ matrix.package }}" secrets: inherit diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index c722c20..ce0eb9b 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -10,6 +10,10 @@ on: CACHIX_AUTH_TOKEN: required: false +permissions: + contents: read + id-token: write + jobs: nix: runs-on: ubuntu-latest