128 lines
4.6 KiB
YAML
128 lines
4.6 KiB
YAML
name: build and cache machines and homes
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
pull_request:
|
|
env:
|
|
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
|
|
NIX_CONFIG: |
|
|
show-trace = true
|
|
extra-substituters = https://cache.cy7.sh/main
|
|
extra-trusted-public-keys = main:Ku31HoEWcBtfggge2VGj+QTkVrQuIwRIMGyfV/5VQP0=
|
|
experimental-features = nix-command flakes
|
|
extra-experimental-features = nix-command flakes
|
|
accept-flake-config = true
|
|
TERM: ansi
|
|
jobs:
|
|
build-machines:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
machine:
|
|
- chunk
|
|
- ytnix
|
|
os:
|
|
- ubuntu-latest
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Maximize build disk space
|
|
uses: easimon/maximize-build-space@v10
|
|
with:
|
|
overprovision-lvm: true
|
|
swap-size-mb: 1024
|
|
remove-dotnet: 'true'
|
|
remove-android: 'true'
|
|
remove-haskell: 'true'
|
|
remove-codeql: 'true'
|
|
remove-docker-images: 'true'
|
|
build-mount-path: /nix
|
|
- name: Install Nix
|
|
uses: nixbuild/nix-quick-install-action@master
|
|
- name: Sync repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Restore and cache Nix store
|
|
uses: nix-community/cache-nix-action@v5.1.0
|
|
with:
|
|
# restore and save a cache using this key
|
|
primary-key: nix-${{ runner.os }}-${{ matrix.machine }}-${{ hashFiles('**/*.nix', 'flake.lock') }}
|
|
# if there's no cache hit, restore a cache by this prefix
|
|
restore-prefixes-first-match: nix-${{ runner.os }}-${{ matrix.machine }}-
|
|
# do purge caches
|
|
purge: true
|
|
# purge all versions of the cache
|
|
purge-prefixes: nix-${{ runner.os }}-
|
|
# created more than this number of seconds ago relative to the start of the `Post Restore` phase
|
|
purge-last-accessed: 86400
|
|
# except the version with the `primary-key`, if it exists
|
|
purge-primary-key: never
|
|
# always save the cache
|
|
save-always: true
|
|
- name: setup attic
|
|
run: |
|
|
nix profile install github:zhaofengli/attic
|
|
attic login cy7 https://cache.cy7.sh "$ATTIC_TOKEN"
|
|
- name: build and cache
|
|
run: |
|
|
package=".#nixosConfigurations."${{ matrix.machine }}".config.system.build.toplevel"
|
|
nix build -L "$package"
|
|
derivation="$(nix path-info --derivation "$package")"
|
|
cache="$(nix-store --query --requisites --include-outputs "$derivation")"
|
|
attic push main --stdin <<< "$cache"
|
|
build-homes:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
home:
|
|
- yt@ytnix
|
|
- yt@chunk
|
|
os:
|
|
- ubuntu-latest
|
|
# - macos-latest
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Maximize build disk space
|
|
uses: easimon/maximize-build-space@v10
|
|
with:
|
|
overprovision-lvm: true
|
|
swap-size-mb: 1024
|
|
remove-dotnet: 'true'
|
|
remove-android: 'true'
|
|
remove-haskell: 'true'
|
|
remove-codeql: 'true'
|
|
remove-docker-images: 'true'
|
|
build-mount-path: /nix
|
|
- uses: nixbuild/nix-quick-install-action@master
|
|
- name: Sync repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Restore and cache Nix store
|
|
uses: nix-community/cache-nix-action@v5.1.0
|
|
with:
|
|
# restore and save a cache using this key
|
|
primary-key: nix-${{ runner.os }}-${{ matrix.home }}-${{ hashFiles('**/*.nix', 'flake.lock') }}
|
|
# if there's no cache hit, restore a cache by this prefix
|
|
restore-prefixes-first-match: nix-${{ runner.os }}-${{ matrix.home }}-
|
|
# do purge caches
|
|
purge: true
|
|
# purge all versions of the cache
|
|
purge-prefixes: nix-${{ runner.os }}-
|
|
# created more than this number of seconds ago relative to the start of the `Post Restore` phase
|
|
purge-last-accessed: 86400
|
|
# except the version with the `primary-key`, if it exists
|
|
purge-primary-key: never
|
|
# always save the cache
|
|
save-always: true
|
|
- name: setup attic
|
|
run: |
|
|
nix profile install github:zhaofengli/attic
|
|
attic login cy7 https://cache.cy7.sh "$ATTIC_TOKEN"
|
|
- name: build and cache
|
|
run: |
|
|
package=".#homeConfigurations."${{ matrix.home }}".activationPackage"
|
|
nix build -L "$package"
|
|
derivation="$(nix path-info --derivation "$package")"
|
|
cache="$(nix-store --query --requisites --include-outputs "$derivation")"
|
|
attic push main --stdin <<< "$cache"
|