From 3f4618d4d2291e16369fbb4ecddd35d6a841833e Mon Sep 17 00:00:00 2001 From: aprilthepink Date: Tue, 9 Apr 2024 20:16:59 +0200 Subject: [PATCH] [feat] GH nix builds --- .github/workflows/nix-flake.yml | 33 +++++++++++++++++++++++++++++++++ flake.nix | 3 +++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/nix-flake.yml diff --git a/.github/workflows/nix-flake.yml b/.github/workflows/nix-flake.yml new file mode 100644 index 0000000..6c2e776 --- /dev/null +++ b/.github/workflows/nix-flake.yml @@ -0,0 +1,33 @@ +name: Nix Flake actions + +on: + pull_request: + push: + branches: + - main + - feat/* + +jobs: + nix-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v24 + - id: set-matrix + name: Generate Nix Matrix + run: | + set -Eeu + matrix="$(nix eval --json '.#githubActions.matrix')" + echo "matrix=$matrix" >> "$GITHUB_OUTPUT" + + nix-build: + needs: nix-matrix + runs-on: ${{ matrix.os }} + strategy: + matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}} + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v24 + - run: nix build -L ".#${{ matrix.attr }}" diff --git a/flake.nix b/flake.nix index f8c9ec4..36d40c2 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,9 @@ imports = [ inputs.treefmt-nix.flakeModule ]; + flake = { config, self', inputs', ... }: { + githubActions = inputs.nix-github-actions.lib.mkGithubMatrix { checks = self'.packages; }; + }; perSystem = { config, self', pkgs, lib, system, ... }: let cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);