Replace the hardcoded list of systems in flake.nix with automatic discovery of host directories under ./systems, and generate the CI build matrix dynamically by evaluating nixosConfigurations rather than maintaining a duplicate list in the workflow.
40 lines
1.1 KiB
YAML
40 lines
1.1 KiB
YAML
name: build_systems
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
push:
|
|
branches: [main]
|
|
schedule:
|
|
- cron: "0 22 * * *"
|
|
|
|
jobs:
|
|
matrix:
|
|
name: generate-matrix
|
|
runs-on: self-hosted
|
|
outputs:
|
|
systems: ${{ steps.systems.outputs.systems }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Collect nixosConfigurations
|
|
id: systems
|
|
run: |
|
|
systems="$(nix eval --accept-flake-config --json \
|
|
'.#nixosConfigurations' \
|
|
--apply 'builtins.attrNames')"
|
|
echo "systems=$systems" >> "$GITHUB_OUTPUT"
|
|
|
|
build:
|
|
name: build-${{ matrix.system }}
|
|
needs: matrix
|
|
runs-on: self-hosted
|
|
strategy:
|
|
matrix:
|
|
system: ${{ fromJSON(needs.matrix.outputs.systems) }}
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Build default package
|
|
run: "nixos-rebuild build --accept-flake-config --flake ./#${{ matrix.system }}"
|
|
- name: copy to nix-cache
|
|
run: nix copy --accept-flake-config --to unix:///host-nix/var/nix/daemon-socket/socket .#nixosConfigurations.${{ matrix.system }}.config.system.build.toplevel
|