diff --git a/.github/workflows/nix-github-actions.yml b/.github/workflows/nix-github-actions.yml new file mode 100644 index 0000000..4b90626 --- /dev/null +++ b/.github/workflows/nix-github-actions.yml @@ -0,0 +1,33 @@ +name: Nix Flake actions + +on: + pull_request: + push: + branches: + - master + - main + +jobs: + nix-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v27 + - 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@v27 + - run: nix build -L '.#${{ matrix.attr }}' diff --git a/flake.lock b/flake.lock index 685c82c..707234d 100644 --- a/flake.lock +++ b/flake.lock @@ -50,6 +50,26 @@ "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1720066371, + "narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "622f829f5fe69310a866c8a6cd07e747c44ef820", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1723175592, @@ -71,6 +91,7 @@ "flake-utils": "flake-utils", "javelin": "javelin", "javelin-rp2040": "javelin-rp2040", + "nix-github-actions": "nix-github-actions", "nixpkgs": "nixpkgs" } }, diff --git a/flake.nix b/flake.nix index 603a3e9..54a1bf1 100644 --- a/flake.nix +++ b/flake.nix @@ -11,10 +11,17 @@ url = "github:jthlim/javelin-steno-rp2040"; flake = false; }; - flake-utils.url = "github:numtide/flake-utils"; + flake-utils = { + url = "github:numtide/flake-utils"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nix-github-actions = { + url = "github:nix-community/nix-github-actions"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, flake-utils, javelin, javelin-rp2040 }: + outputs = { self, nixpkgs, flake-utils, javelin, javelin-rp2040, nix-github-actions }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { @@ -32,6 +39,7 @@ deps = with pkgs; [ cmake gcc-arm-embedded local-pico-sdk python3]; my_yask_file = ./yask.h; in rec { + githubActions = nix-github-actions.lib.mkGithubMatrix { checks = self.packages; }; packages.default = pkgs.stdenv.mkDerivation { name = "javelin-rp2040"; src = javelin-rp2040;