Skip to content

update cache

update cache #325

Workflow file for this run

name: "update cache"
on:
workflow_run:
workflows: ["tests are"]
types: [completed]
branches: [main]
jobs:
# For single user this isn't a big deal. Hopefully not a deal breaker for
# multi-user.
list-users:
runs-on: ubuntu-latest
outputs:
user_matrix: ${{ steps.set-matrix.outputs.user_matrix }}
config_matrix: ${{ steps.set-matrix.outputs.config_matrix }}
steps:
- uses: actions/checkout@v3
with:
ref: main
# 1) create a https://app.cachix.org account
# 2) make a cache called <username> (or whatever, but update accordingly): https://app.cachix.org/cache
# 3) create an auth token: https://app.cachix.org/cache/<username>/settings/authtokens
# 4) add the CACHIX_TOKEN: https://github.com/<username>/.dots/settings/secrets/actions/new
- name: "provision home-mananger"
uses: ./.github/actions/runner
id: runner
with:
cachix-endpoint: "${{ github.repository_owner }}"
cachix-token: '${{ secrets.CACHIX_TOKEN }}'
- id: set-matrix
run: |
users=$(find nix/home/users/*.nix -type f ! -name "user.nix")
test -z "$user" && user="user.nix"
user_matrix=$(echo $user | xargs basename -s .nix | jq -R -s -c 'split("\n")[:-1]')
config_matrix=$(nix eval --raw ".#_configs" | jq -R -s -c 'split(" ")')
echo "::set-output name=user_matrix::$user_matrix"
echo "::set-output name=config_matrix::$config_matrix"
echo $config_matrix $user_matrix # Sanity check
- name: "build and cache dots-manager"
if: ${{ success() }}
run: |
nix build --json "./dots-manager#" | jq -r '(.[]|.outputs|.out)' | cachix push $GITHUB_REPOSITORY_OWNER;
# For each user, build each system.
build:
runs-on: ubuntu-latest
needs: list-users
strategy:
matrix:
users: ${{ fromJson(needs.list-users.outputs.user_matrix) }}
configs: ${{ fromJson(needs.list-users.outputs.config_matrix) }}
steps:
- uses: actions/checkout@v3
with:
ref: main
- name: "provision home-mananger"
uses: ./.github/actions/runner
id: runner
with:
user: ${{ matrix.users }}
cachix-endpoint: "${{ github.repository_owner }}"
cachix-token: '${{ secrets.CACHIX_TOKEN }}'
- name: "build and cache systems"
if: ${{ success() }}
run: |
nix build --json ".#nixosConfigurations.${{ matrix.configs }}.config.system.build.toplevel" \
| jq -r '(.[]|.outputs|.out)' | cachix push $GITHUB_REPOSITORY_OWNER;