Homelab update #118
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: nix build | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
define-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.eval-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v30 | |
- id: eval-matrix | |
name: Generate Nix Matrix | |
run: | | |
set -Eeu | |
matrix="$(nix eval --accept-flake-config --json '.#githubActions.matrix')" | |
echo "matrix=$matrix" >> "$GITHUB_OUTPUT" | |
build: | |
runs-on: ubuntu-latest | |
needs: define-matrix | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.define-matrix.outputs.matrix) }} | |
concurrency: | |
group: ${{ github.workflow }}.${{ github.event.pull_request.number || github.ref }}.${{ matrix.host }} | |
cancel-in-progress: true | |
steps: | |
- uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: true | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v30 | |
with: | |
extra_nix_config: | | |
max-jobs = auto | |
builders = @/etc/nix/machines | |
max-substitution-jobs = 128 | |
http-connections = 128 | |
auto-optimise-store = true | |
- name: Initialize attic cache watcher | |
uses: ryanccn/attic-action@v0 | |
with: | |
endpoint: "https://attic.joinemm.dev" | |
cache: "cache" | |
token: '${{ secrets.ATTIC_AUTH_TOKEN }}' | |
- name: Configure remote builders | |
run: | | |
sudo sh -c "umask 377; echo '${{ secrets.BUILDER_SSH_KEY }}' >/etc/nix/id_builder_key" | |
sudo sh -c "echo 'ssh://[email protected] aarch64-linux /etc/nix/id_builder_key 20 1 nixos-test,benchmark,big-parallel,kvm - -' >/etc/nix/machines" | |
sudo sh -c "echo 'hetzarm.vedenemo.dev ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILx4zU4gIkTY/1oKEOkf9gTJChdx/jR3lDgZ7p/c7LEK' >>/etc/ssh/ssh_known_hosts" | |
sudo sh -c "echo 'ssh://[email protected] x86_64-linux,i686-linux /etc/nix/id_builder_key 16 1 kvm,benchmark,big-parallel,nixos-test - -' >>/etc/nix/machines" | |
sudo sh -c "echo 'builder.vedenemo.dev ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHSI8s/wefXiD2h3I3mIRdK+d9yDGMn0qS5fpKDnSGqj' >>/etc/ssh/ssh_known_hosts" | |
- name: Build ${{ matrix.host }} | |
run: nix run nixpkgs#nixos-rebuild -- build --accept-flake-config --flake ".#${{ matrix.host }}" |