Skip to content

Commit

Permalink
Switch nix cache solution because it was clunky
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaczero committed Feb 19, 2024
1 parent 1f2dafd commit 798f587
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@ jobs:
uses: actions/checkout@v4

- name: Install Nix
uses: nixbuild/nix-quick-install-action@v26
uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixpkgs-23.11-darwin

- name: Cache Nix store
uses: nix-community/[email protected]
uses: actions/cache@v4
id: nix-cache
with:
primary-key: nix-${{ runner.os }}-${{ hashFiles('shell.nix') }}
key: nix-${{ runner.os }}-${{ hashFiles('shell.nix') }}
path: /tmp/nix-cache

- name: Install Nix channels
- name: Import Nix store cache
if: ${{ steps.nix-cache.outputs.cache-hit == 'true' }}
run: |
nix-channel --add https://nixos.org/channels/nixpkgs-23.11-darwin nixpkgs
nix-channel --update
nix-store --import < /tmp/nix-cache
- name: Cache Python packages
uses: actions/cache@v4
Expand All @@ -44,6 +48,11 @@ jobs:
run: |
nix-shell --pure --run true
- name: Export Nix store cache
if: ${{ steps.nix-cache.outputs.cache-hit == 'false' }}
run: |
nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nix-cache
- name: Build container image
run: |
echo "IMAGE_PATH=$(nix-build --no-out-link)" >> $GITHUB_ENV
Expand All @@ -64,10 +73,6 @@ jobs:
run: |
scp "${{ env.IMAGE_PATH }}" remote:~
- name: Cleanup cache after Nix build
run: |
nix-store --delete "${{ env.IMAGE_PATH }}"
- name: Deploy on remote
run: |
ssh remote <<\EOF
Expand Down

0 comments on commit 798f587

Please sign in to comment.