diff --git a/.github/workflows/nix-github-actions.yml b/.github/workflows/nix-github-actions.yml new file mode 100644 index 0000000..7d329e8 --- /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@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 650ece3..79e7481 100644 --- a/flake.nix +++ b/flake.nix @@ -2,10 +2,13 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nix-github-actions.url = "github:nix-community/nix-github-actions"; + nix-github-actions.inputs.nixpkgs.follows = "nixpkgs"; + utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, ... } @inputs: inputs.utils.lib.eachSystem [ + outputs = { self, nixpkgs, nix-github-actions, ... } @inputs: inputs.utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ] (system: let pkgs = import nixpkgs { @@ -20,6 +23,10 @@ }); }; in { + githubActions = nix-github-actions.lib.mkGithubMatrix { checks = self.packages; }; + packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello; + packages.x86_64-linux.default = self.packages.x86_64-linux.hello; + hydraJobs."tester" = self.defaultPackage; # hydraJobs."tester-container" = self.container;