Skip to content

Commit

Permalink
flake: add nix-github-actions for running checks in GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
minijackson committed Dec 19, 2024
1 parent d1c28b7 commit cb500b5
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 3 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Nix flake checks"

on:
pull_request:
push:

permissions:
contents: read

jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: cachix/install-nix-action@3715ab1a11cac9e991980d7b4a28d80c7ebdd8f9 # v27
- id: set-matrix
name: Generate Nix checks matrix
run: |
set -Eeu
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
nix-build:
name: ${{ matrix.name }} (${{ matrix.system }})
needs: nix-matrix
runs-on: ${{ matrix.os }}
env:
CHECK_ATTR: ${{ matrix.attr }}
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: cachix/install-nix-action@3715ab1a11cac9e991980d7b4a28d80c7ebdd8f9 # v27
- uses: DeterminateSystems/magic-nix-cache-action@87b14cf437d03d37989d87f0fa5ce4f5dc1a330b # v8
with:
diagnostic-endpoint: ""
- run: nix build -L ".#${CHECK_ATTR}"
27 changes: 24 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@
url = "github:minijackson/sphinxcontrib-nixdomain";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-github-actions = {
url = "github:nix-community/nix-github-actions";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
self,
flake-utils,
nixpkgs,
nix-github-actions,
...
} @ inputs: let
overlay = import ./pkgs self.lib inputs;
Expand Down Expand Up @@ -129,5 +134,7 @@
defaultTemplate = self.templates.default;

formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra;

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

0 comments on commit cb500b5

Please sign in to comment.