Skip to content

Define the initial NixOS configuration of webforge in a flake with CI support #16

Define the initial NixOS configuration of webforge in a flake with CI support

Define the initial NixOS configuration of webforge in a flake with CI support #16

Workflow file for this run

name: Nix
on:
push:
branches:
- main
paths:
- '.github/workflows/nix.yml'
- 'nix/**'
- 'flake.*'
pull_request:
paths:
- '.github/workflows/nix.yml'
- 'nix/**'
- 'flake.*'
jobs:
check:
name: Check
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Install Nix
id: install_nix
uses: nixbuild/nix-quick-install-action@v28
- name: Check Nix Flake
id: check
run: |
nix flake show
nix flake check
- name: Set matrix
id: set-matrix
run: |
# Create a "matrix" targeting the systems we want to check (and later deploy),
# which will be consumed by the next job to start one build per system.
echo 'matrix={"include":[{"target":"webforge","hostname":"webforge","domain":"tahoe-lafs.org"}]}' \
>> $GITHUB_OUTPUT
build:
name: Build
runs-on: ubuntu-24.04
if: github.event_name == 'pull_request'
needs: check
strategy:
fail-fast: false
# Consuming the matrix created above
matrix: ${{fromJson(needs.check.outputs.matrix)}}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Install Nix
id: install_nix
uses: nixbuild/nix-quick-install-action@v28
- name: Restore and cache Nix store ${{ matrix.target }}
uses: nix-community/cache-nix-action@v5
with:
# restore and save a cache using this key
primary-key: ${{ runner.os }}-Nix-${{ matrix.target }}-${{ hashFiles('flake.*', 'nix/common/*.nix', 'nix/modules/**.nix', format('nix/hosts/{0}/*.nix', matrix.target)) }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: ${{ runner.os }}-Nix-${{ matrix.target }}-
# collect garbage until Nix store size (in bytes) is at most this number
# before trying to save a new cache
gc-max-store-size-linux: 1073741824
# do purge caches
purge: true
# purge all versions of the cache
purge-prefixes: ${{ runner.os }}-Nix-${{ matrix.target }}-
# created more than 0 seconds ago relative to the start of the `Post Restore` phase
purge-created: 0
# except the version with the `primary-key`, if it exists
purge-primary-key: never
- name: Build nixosConfiguration for ${{ matrix.target }}
id: check_target
run: |
nix build .#nixosConfigurations.${{ matrix.target }}.config.system.build.toplevel