File tree 4 files changed +80
-21
lines changed
4 files changed +80
-21
lines changed Original file line number Diff line number Diff line change
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 }}"
Original file line number Diff line number Diff line change 3
3
4
4
inputs = {
5
5
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
+ } ;
7
10
treefmt-nix = {
8
11
# todo switch back to numtide/treefmt-nix once merged
9
12
url = "github:brianmcgee/treefmt-nix/feat/pipelines" ;
16
19
gomod2nix = {
17
20
url = "github:nix-community/gomod2nix" ;
18
21
inputs . nixpkgs . follows = "nixpkgs" ;
19
- inputs . flake-utils . follows = "devshell/flake-utils" ;
22
+ inputs . flake-utils . follows = "devshell/flake-utils" ;
20
23
} ;
21
24
nix-filter . url = "github:numtide/nix-filter" ;
22
25
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
+ } ;
23
30
} ;
24
31
25
32
outputs = inputs @ { flake-parts , ...} :
Original file line number Diff line number Diff line change 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
+
2
12
perSystem = { self' , ...} : {
13
+ # mixin every package
3
14
checks = with lib ; mapAttrs' ( n : nameValuePair "package-${ n } " ) self' . packages ;
4
15
} ;
5
16
}
You can’t perform that action at this time.
0 commit comments