Skip to content

Commit

Permalink
Create GitHub Actions matrix from nix flake show
Browse files Browse the repository at this point in the history
  • Loading branch information
matrss committed Jan 10, 2024
1 parent bf7c47f commit 5e0dd4a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 36 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build-flake-outputs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build flake outputs

on:
pull_request:
push:
branches:
- main

jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24
- id: set-matrix
name: Generate matrix
run: |
matrix=$(
nix flake show --refresh --json "." |
jq '{ attr: ((path(.. | select(.type? == "derivation")) | map((if (. | contains(".")) then "\"" + . + "\"" else . end)) | join(".")),
(path(.. | select(.type? == "nixos-configuration")) | map((if (. | contains(".")) then "\"" + . + "\"" else . end)) | join(".") | . + ".config.system.build.toplevel"))
}' |
jq --slurp --compact-output
)
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
nix-build:
needs: nix-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24
- uses: cachix/cachix-action@v12
with:
name: matrss
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build -L '.#${{ matrix.attr }}'
36 changes: 0 additions & 36 deletions .github/workflows/nix-github-actions.yml

This file was deleted.

0 comments on commit 5e0dd4a

Please sign in to comment.