feat: add caching for Nix store in GitHub Actions workflow #2
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: Test NixOS Config | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
host: | |
- nixos-vm | |
- work-vm | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Nix | |
uses: cachix/install-nix-action@v27 | |
with: | |
extra_nix_config: | | |
system-features = nixos-test benchmark big-parallel kvm | |
experimental-features = nix-command flakes | |
nix_path: nixpkgs=channel:nixos-unstable | |
- name: Cache Nix store | |
uses: actions/cache@v2 | |
with: | |
path: /nix/store | |
key: ${{ runner.os }}-nix-${{ hashFiles('**/flake.lock') }} | |
restore-keys: | | |
${{ runner.os }}-nix- | |
- name: Test Nix Flake | |
run: | | |
nix flake check | |
- name: Build NixOS configuration for ${{ matrix.system }} | |
run: | | |
nix build .#nixosConfigurations.${{ matrix.system }}.config.system.build.vm | |
- name: Run NixOS tests for ${{ matrix.system }} | |
run: | | |
./result/bin/run-nixos-vm |