Skip to content

feat: exposes standalone bootstrap writer targets #446

feat: exposes standalone bootstrap writer targets

feat: exposes standalone bootstrap writer targets #446

Workflow file for this run

name: flake-check
on:
push:
branches: ["main"]
pull_request:
jobs:
find-templates:
name: Find templates
runs-on: ubuntu-latest
outputs:
templates: ${{ steps.templates.outputs.templates }}
steps:
- uses: actions/checkout@v4
- id: templates
run: |
templates=$(find templates -mindepth 2 -maxdepth 2 -name flake.nix -print0 | xargs -0 dirname | xargs -n 1 basename | jq -R | jq -sc)
echo "$templates"
echo "templates=$templates" >> $GITHUB_OUTPUT
bootstrap-minimal:
name: Bootstrap templates/minimal
runs-on: ubuntu-latest
env:
NIX_PATH: "nixpkgs=https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"
steps:
- uses: wimpysworld/nothing-but-nix@v10
- uses: cachix/install-nix-action@v31
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: actions/checkout@v4
- run: |
cd templates/minimal
rm flake.nix
mv flake-file.nix flake.nix
nix-shell "https://github.com/$GITHUB_REPOSITORY/archive/$GITHUB_SHA.zip" -A flake-file.sh --run bootstrap
cat flake-file.nix flake.nix
nix flake check
sed -i 's#hello = "mundo"#hello = "world"#' flake-file.nix
if nix flake check; then exit 1; fi
sed -i 's#hello = "world"#hello = "monde"#' flake-file.nix
nix flake check
bootstrap-tests:
name: Bootstrap apps
runs-on: ubuntu-latest
env:
NIX_PATH: "nixpkgs=https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"
# write-tack resolves refs via api.github.com; anonymous rate limits flake on shared runners
GITHUB_TOKEN: ${{ github.token }}
steps:
- uses: wimpysworld/nothing-but-nix@v10
- uses: cachix/install-nix-action@v31
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: actions/checkout@v4
- run: nix-shell ./dev/bootstrap-tests.nix --run test-all
template:
name: Check template ${{matrix.template}}
needs: [nix-fmt, find-templates]
runs-on: ubuntu-latest
strategy:
matrix:
template: ${{ fromJSON(needs.find-templates.outputs.templates) }}
exclude:
- template: minimal
- template: flakeless-parts
- template: tack
steps:
- uses: wimpysworld/nothing-but-nix@v10
- uses: cachix/install-nix-action@v31
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: |
set -uveo pipefail
cat <<EOF | tee forced.nix
{ lib, ... }:
{
flake-file.inputs.flake-file.url = lib.mkForce "github:$GITHUB_REPOSITORY/$GITHUB_SHA";
}
EOF
mkdir templated; cd templated
nix flake init -t github:$GITHUB_REPOSITORY/$GITHUB_SHA#${{ matrix.template }}
nix run .#write-flake -L --show-trace --override-input flake-file "github:$GITHUB_REPOSITORY/$GITHUB_SHA"
if test -d ./modules; then cp ../forced.nix ./modules/; fi;
if test -d ./flake-parts; then cp ../forced.nix ./flake-parts/; fi;
nix run .#write-flake -L --show-trace --override-input flake-file "github:$GITHUB_REPOSITORY/$GITHUB_SHA"
nix flake metadata
nix run .#write-flake -L --show-trace --override-input flake-file "github:$GITHUB_REPOSITORY/$GITHUB_SHA"
nix flake check -L --show-trace --override-input flake-file "github:$GITHUB_REPOSITORY/$GITHUB_SHA"
npins:
needs: [nix-fmt]
name: Check npins
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'npins') }}
steps:
- uses: actions/checkout@v4
- uses: wimpysworld/nothing-but-nix@v10
- uses: cachix/install-nix-action@v31
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: |
set -e -o pipefail
cd templates/npins
sed -i 's/# flake-file = import/flake-file = import/' default.nix
echo "{ inputs, ... }: { npins.pkgs = import inputs.nixpkgs {}; }" | tee modules/pkgs.nix
nix-shell . -A flake-file.sh --run write-npins
flakeless-parts:
needs: [nix-fmt]
name: Check flakeless-parts
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'flakeless-parts') }}
steps:
- uses: actions/checkout@v4
- uses: wimpysworld/nothing-but-nix@v10
- uses: cachix/install-nix-action@v31
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: |
set -e -o pipefail
cd templates/flakeless-parts
sed -i 's/# flake-file = import/flake-file = import/' default.nix
nix run .#write-npins
unflake:
needs: [nix-fmt]
name: Check unflake
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'unflake') }}
env:
NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"
steps:
- uses: actions/checkout@v4
- uses: wimpysworld/nothing-but-nix@v10
- uses: cachix/install-nix-action@v31
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: |
set -e -o pipefail
cd templates/unflake
sed -i 's/# flake-file = import/flake-file = import/' default.nix
nix-shell . -A flake-file.sh --run 'write-unflake --verbose'
tack:
needs: [nix-fmt]
name: Check tack
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'tack') }}
env:
GITHUB_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
- uses: wimpysworld/nothing-but-nix@v10
- uses: cachix/install-nix-action@v31
- uses: DeterminateSystems/magic-nix-cache-action@main
# The tack template is lock-less (its flake.nix declares no inputs), so
# the generic template job cannot --override-input it. Instead the
# template's recomposable tackOverrides arg injects this checkout's
# flake-file, exercising the override path at the same time.
- run: |
set -e -o pipefail
cd templates/tack
local_flake_file='tackOverrides.flake-file = import ./../../modules;'
nix build -L --impure --expr "
((import ./.) { $local_flake_file }).packages.\${builtins.currentSystem}.write-tack
"
./result/bin/write-tack
git diff --exit-code .tack/pins.toml
nix build -L --impure --expr "
((import ./.) { $local_flake_file }).devShells.\${builtins.currentSystem}.default
"
dev:
needs: [bootstrap-minimal, bootstrap-tests, nix-fmt]
name: Check flake dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wimpysworld/nothing-but-nix@v10
- uses: cachix/install-nix-action@v31
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: cd dev && nix flake check && nix flake metadata && nix flake check
nix-fmt:
name: Nix Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wimpysworld/nothing-but-nix@v10
- uses: cachix/install-nix-action@v31
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix run -L ./dev#fmt -- --ci