Skip to content

Commit ebfd17b

Browse files
committed
feat: add nix github workflow
Signed-off-by: Brian McGee <[email protected]>
1 parent a3fb127 commit ebfd17b

File tree

4 files changed

+80
-21
lines changed

4 files changed

+80
-21
lines changed

.github/workflows/nix.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Nix Flake Actions
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
nix-matrix:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
matrix: ${{ steps.set-matrix.outputs.matrix }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: cachix/install-nix-action@v26
17+
- id: set-matrix
18+
name: Generate Nix Matrix
19+
run: |
20+
set -Eeu
21+
matrix="$(nix eval --json '.#githubActions.matrix')"
22+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
23+
24+
nix-build:
25+
needs: nix-matrix
26+
runs-on: ${{ matrix.os }}
27+
strategy:
28+
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: cachix/install-nix-action@v26
32+
- uses: cachix/cachix-action@v14
33+
with:
34+
name: numtide
35+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
36+
- run: nix build -L ".#${{ matrix.attr }}"

flake.lock

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

flake.nix

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
inputs = {
55
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6-
flake-parts.url = "github:hercules-ci/flake-parts";
6+
flake-parts = {
7+
url = "github:hercules-ci/flake-parts";
8+
inputs.nixpkgs-lib.follows = "nixpkgs";
9+
};
710
treefmt-nix = {
811
# todo switch back to numtide/treefmt-nix once merged
912
url = "github:brianmcgee/treefmt-nix/feat/pipelines";
@@ -16,10 +19,14 @@
1619
gomod2nix = {
1720
url = "github:nix-community/gomod2nix";
1821
inputs.nixpkgs.follows = "nixpkgs";
19-
inputs.flake-utils.follows ="devshell/flake-utils";
22+
inputs.flake-utils.follows = "devshell/flake-utils";
2023
};
2124
nix-filter.url = "github:numtide/nix-filter";
2225
flake-compat.url = "github:nix-community/flake-compat";
26+
nix-github-actions = {
27+
url = "github:nix-community/nix-github-actions";
28+
inputs.nixpkgs.follows = "nixpkgs";
29+
};
2330
};
2431

2532
outputs = inputs @ {flake-parts, ...}:

nix/checks.nix

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
{lib, ...}: {
1+
{
2+
lib,
3+
inputs,
4+
self,
5+
...
6+
}: {
7+
# generate github actions matrix using the flake's checks
8+
flake.githubActions = inputs.nix-github-actions.lib.mkGithubMatrix {
9+
checks = lib.getAttrs ["x86_64-linux" "x86_64-darwin"] self.checks;
10+
};
11+
212
perSystem = {self', ...}: {
13+
# mixin every package
314
checks = with lib; mapAttrs' (n: nameValuePair "package-${n}") self'.packages;
415
};
516
}

0 commit comments

Comments
 (0)