diff --git a/.github/workflows/build-checks.yml b/.github/workflows/build-checks.yml new file mode 100644 index 0000000..3d31c5f --- /dev/null +++ b/.github/workflows/build-checks.yml @@ -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}" diff --git a/flake.lock b/flake.lock index 34d1452..5083064 100644 --- a/flake.lock +++ b/flake.lock @@ -100,6 +100,26 @@ } }, "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1731952509, + "narHash": "sha256-p4gB3Rhw8R6Ak4eMl8pqjCPOLCZRqaehZxdZ/mbFClM=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "7b5f051df789b6b20d259924d349a9ba3319b226", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nix-github-actions_2": { "inputs": { "nixpkgs": [ "poetry2nix", @@ -120,7 +140,7 @@ "type": "github" } }, - "nix-github-actions_2": { + "nix-github-actions_3": { "inputs": { "nixpkgs": [ "sphinxcontrib-nixdomain", @@ -161,7 +181,7 @@ "poetry2nix": { "inputs": { "flake-utils": "flake-utils_3", - "nix-github-actions": "nix-github-actions", + "nix-github-actions": "nix-github-actions_2", "nixpkgs": [ "nixpkgs" ], @@ -185,7 +205,7 @@ "pyproject-nix": { "inputs": { "mdbook-nixdoc": "mdbook-nixdoc", - "nix-github-actions": "nix-github-actions_2", + "nix-github-actions": "nix-github-actions_3", "nixpkgs": [ "sphinxcontrib-nixdomain", "nixpkgs" @@ -209,6 +229,7 @@ "inputs": { "bash-lib": "bash-lib", "flake-utils": "flake-utils_2", + "nix-github-actions": "nix-github-actions", "nixpkgs": "nixpkgs", "poetry2nix": "poetry2nix", "sphinxcontrib-nixdomain": "sphinxcontrib-nixdomain" diff --git a/flake.nix b/flake.nix index 7ecdb45..bb3ab07 100644 --- a/flake.nix +++ b/flake.nix @@ -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; @@ -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;}; }; }