Skip to content

Fix warnings from renamed options #67

Fix warnings from renamed options

Fix warnings from renamed options #67

name: Build flake outputs
on:
pull_request:
push:
branches:
- main
jobs:
discover:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
- id: set-matrix
name: Generate matrix
run: |
matrix=$(
nix flake show --refresh --all-systems --json "." |
jq '
def system_to_os: {
"aarch64-linux": "ubuntu-latest",
"x86_64-darwin": "macos-latest",
"x86_64-linux": "ubuntu-latest",
}[.] // empty;
def quote: map(if contains(".") then "\"" + . + "\"" else . end);
(path(.. | select(.type? == "derivation")) | quote | { attr: join("."), os: .[1] | system_to_os }),
(path(.. | select(.type? == "nixos-configuration")) | quote | join(".") | . + ".config.system.build.toplevel" | { attr: . , os: "ubuntu-latest" })
' |
jq --slurp --compact-output
)
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
build:
name: ${{ matrix.attr }}
needs: discover
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.discover.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
uses: docker/setup-qemu-action@v3
- uses: cachix/install-nix-action@v25
with:
extra_nix_config: |
accept-flake-config = true
always-allow-substitutes = true
${{ startsWith(matrix.os, 'ubuntu') && 'extra-platforms = aarch64-linux' || ' ' }}
- uses: cachix/cachix-action@v14
with:
name: matrss
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Get store derivation
run: |
drv=$(
{ { nix path-info --derivation '.#${{ matrix.attr }}' 1>&3; } 2>&1 |
tee /dev/stderr |
if grep 'trace: warning:' > /dev/null; then echo "warnings=true" >> "$GITHUB_ENV"; else true; fi
} 3>&1
)
echo "drv=$drv" >> "$GITHUB_ENV"
- name: Get output hash
run: |
hash=$(nix derivation show $drv^* | jq -r ".\"$drv\".outputs.out.path" | cut -d/ -f4 | cut -d- -f1)
echo "hash=$hash" >> "$GITHUB_ENV"
- name: Check if output is cached
run: |
is_cached() {
curl --fail "https://matrss.cachix.org/$hash.narinfo" > /dev/null 2>&1
}
if is_cached $hash; then
echo "output is cached, nothing to do"
echo "skip_build=true" >> "$GITHUB_ENV"
fi
- name: Build output
if: ${{ env.skip_build != 'true' }}
run: nix build -L $drv^*
- name: Check if there were warnings
if: ${{ github.ref != 'refs/heads/main' }}
run: test ! "$warnings" = "true"