diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000..8e5471ee --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,74 @@ +name: Check + +on: + workflow_dispatch: # can be triggered manually + pull_request: + types: + - opened + - reopened + - synchronize + push: + branches-ignore: + - update/* + paths-ignore: + - "LICENSE" + +jobs: + flake-checker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install nix + uses: cachix/install-nix-action@v31 + - name: Run flake checker + uses: DeterminateSystems/flake-checker-action@main + + build-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install nix + uses: cachix/install-nix-action@v31 + - name: Generate Nix Matrix + id: set-matrix + run: | + set -Eeu + matrix="$(nix eval --json .#githubActions.matrix)" + echo "matrix=$matrix" >> "$GITHUB_OUTPUT" + + build: + name: ${{ matrix.name }} (${{ matrix.system }}) + needs: + - build-matrix + runs-on: ${{ matrix.os }} + strategy: + matrix: ${{ fromJSON(needs.build-matrix.outputs.matrix) }} + steps: + - name: Free disk space + uses: wimpysworld/nothing-but-nix@main + with: + # Options: holster, carve, cleave (default), rampage + hatchet-protocol: rampage + root-safe-haven: "1024" # Default 2048MB + mnt-safe-haven: "512" # Default 1024MB + - name: Checkout + uses: actions/checkout@v4 + - name: Install nix + uses: cachix/install-nix-action@v31 + - name: Setup nix cache + uses: cachix/cachix-action@v16 + with: + name: nix-community + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - name: Build ${{ matrix.attr }} + env: + attr: ${{ matrix.attr }} + run: | + nix build ".#$attr" \ + --abort-on-warn \ + --print-build-logs \ + --log-format raw diff --git a/flake/default.nix b/flake/default.nix index 58db3e79..df44a532 100644 --- a/flake/default.nix +++ b/flake/default.nix @@ -34,6 +34,7 @@ checks = "dev"; devShells = "dev"; formatter = "dev"; + githubActions = "dev"; }; # For any output attrs normally defined by the root flake configuration, diff --git a/flake/dev/flake.lock b/flake/dev/flake.lock index d08e3357..ca24e707 100644 --- a/flake/dev/flake.lock +++ b/flake/dev/flake.lock @@ -135,6 +135,26 @@ "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "dev-nixpkgs" + ] + }, + "locked": { + "lastModified": 1737420293, + "narHash": "sha256-F1G5ifvqTpJq7fdkT34e/Jy9VCyzd5XfJ9TO8fHhJWE=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "f4158fa080ef4503c8f4c820967d946c2af31ec9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "root": { "inputs": { "dev-nixpkgs": "dev-nixpkgs", @@ -143,6 +163,7 @@ "git-hooks": "git-hooks", "home-manager": "home-manager", "nix-darwin": "nix-darwin", + "nix-github-actions": "nix-github-actions", "treefmt-nix": "treefmt-nix" } }, diff --git a/flake/dev/flake.nix b/flake/dev/flake.nix index ba96bbc6..4d0f653e 100644 --- a/flake/dev/flake.nix +++ b/flake/dev/flake.nix @@ -32,6 +32,11 @@ inputs.nixpkgs.follows = "dev-nixpkgs"; }; + nix-github-actions = { + url = "github:nix-community/nix-github-actions"; + inputs.nixpkgs.follows = "dev-nixpkgs"; + }; + treefmt-nix = { url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "dev-nixpkgs"; diff --git a/flake/dev/tests.nix b/flake/dev/tests.nix index 1067ca7a..2fbe539d 100644 --- a/flake/dev/tests.nix +++ b/flake/dev/tests.nix @@ -1,5 +1,6 @@ { self, + inputs, helpers, ... }: @@ -11,4 +12,9 @@ inherit helpers self; }; }; + + # Output a build matrix for CI + flake.githubActions = inputs.nix-github-actions.lib.mkGithubMatrix { + inherit (self) checks; + }; }