nixos-config/.github/workflows/build-packages.yml
2025-04-15 20:19:08 -04:00

69 lines
2 KiB
YAML

name: build and cache packages
on:
workflow_dispatch:
inputs:
package:
description: "package to build"
required: false
type: string
env:
TERM: ansi
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets. AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
AWS_ENDPOINT_URL: https://s3.cy7.sh
jobs:
build-packages:
strategy:
fail-fast: false
matrix:
package:
- ${{ inputs.package }}
os:
- ubuntu-latest
- ubuntu-24.04-arm
- macos-latest
- macos-13
runs-on: ${{ matrix.os }}
steps:
- name: setup binary cache key
run: echo -n "${{ secrets.NIX_CACHE_SECRET_KEY }}" | xxd -p -r > ${{ runner.temp }}/cache-priv-key.pem
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
enable_kvm: true
extra_nix_config: |
show-trace = true
experimental-features = nix-command flakes
accept-flake-config = true
system-features = nixos-test benchmark big-parallel kvm
secret-key-files = ${{ runner.temp }}/cache-priv-key.pem
extra-substituters = https://nixcache.cy7.sh
extra-trusted-public-keys = nixcache.cy7.sh:DN3d1dt0wnXfTH03oVmTee4KgmdNdB0NY3SuzA8Fwx8=
- run: nix build -L ${{ matrix.package }}
- name: cache result
# https://stackoverflow.com/a/58859404
if: '!cancelled()'
run: |
nix run github:cything/nixcp -- \
push \
--bucket nixcache \
--signing-key ${{ runner.temp }}/cache-priv-key.pem \
-u https://nix-community.cachix.org \
"${{ matrix.package }}"
- name: prepare tarball to upload
run: nix run github:nixos/nixpkgs#gnutar hcvf result.tar result
- name: upload result
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: result.tar
if-no-files-found: error