Skip to content

Commit 2bb46e2

Browse files
committed
ci: add new GHA pipeline running nix flake checks
1 parent e5f355d commit 2bb46e2

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Nix Flake Actions
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
jobs:
11+
nix-matrix:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
matrix: ${{ steps.set-matrix.outputs.matrix }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: cachix/install-nix-action@v27
18+
- id: set-matrix
19+
name: Generate Nix Matrix
20+
run: |
21+
set -Eeu
22+
matrix="$(nix eval --json '.#githubActions.matrix')"
23+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
24+
25+
nix-flake-checks:
26+
needs: nix-matrix
27+
runs-on: ${{ matrix.os }}
28+
strategy:
29+
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: cachix/install-nix-action@v27
33+
- uses: cachix/cachix-action@v15
34+
with:
35+
name: jaen-robotnix
36+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
37+
- run: nix build -L ".#${{ matrix.attr }}"
38+
39+
nix-flake-check-template:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: cachix/install-nix-action@v27
44+
- uses: cachix/cachix-action@v15
45+
with:
46+
name: jaen-robotnix
47+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
48+
- name: "Check the robotnix flake"
49+
run: |
50+
# Don't run checks here, the `nix-flake-checks` job takes care of it
51+
nix flake check --no-build
52+
- name: "Check the templated robotnix flake"
53+
run: |
54+
export ORIG_DIR="$PWD"
55+
cd "$(mktemp -d)"
56+
57+
nix flake init -t "$ORIG_DIR"
58+
nix flake check --override-input robotnix "$ORIG_DIR"

flake.lock

+22-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
treefmt-nix.url = "github:numtide/treefmt-nix";
1515
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs-unstable";
16+
17+
nix-github-actions.url = "github:nix-community/nix-github-actions";
18+
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
1619
};
1720

1821
outputs = args: import ./flake/outputs.nix args;

flake/outputs.nix

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
flake-compat,
77
treefmt,
88
treefmt-nix,
9+
nix-github-actions,
910
...
1011
}@inputs:
1112
let
@@ -89,4 +90,6 @@ in
8990
'';
9091
};
9192
};
93+
94+
githubActions = nix-github-actions.lib.mkGithubMatrix { inherit (self) checks; };
9295
}

0 commit comments

Comments
 (0)