Skip to content

Commit 8f8c72e

Browse files
committed
ci: add new GHA pipeline running nix flake checks
1 parent 43e49fb commit 8f8c72e

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-0
lines changed
Lines changed: 58 additions & 0 deletions
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

.yamlfmt.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
line_ending: "lf"
2+
formatter:
3+
indent: 2
4+
retain_line_breaks_single: true
5+
scan_folded_as_literal: true

flake.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
treefmt-nix.url = "github:numtide/treefmt-nix";
1313
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs-unstable";
14+
15+
nix-github-actions.url = "github:nix-community/nix-github-actions";
16+
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
1417
};
1518

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

flake/outputs.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
androidPkgs,
66
flake-compat,
77
treefmt-nix,
8+
nix-github-actions,
89
...
910
}@inputs:
1011
let
@@ -90,4 +91,5 @@ in
9091
};
9192
};
9293

94+
githubActions = nix-github-actions.lib.mkGithubMatrix { inherit (self) checks; };
9395
}

0 commit comments

Comments
 (0)