From c1f609ad3b50119ef556904dc25839b1aa5af79f Mon Sep 17 00:00:00 2001 From: Benjamin Staffin Date: Wed, 23 Oct 2024 14:21:18 -0400 Subject: [PATCH] Try setting up github actions --- .github/workflows/nix-github-actions.yml | 32 ++++++++++++++++++++++++ flake.lock | 21 ++++++++++++++++ flake.nix | 12 +++++++-- 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/nix-github-actions.yml diff --git a/.github/workflows/nix-github-actions.yml b/.github/workflows/nix-github-actions.yml new file mode 100644 index 0000000..b9a8fdc --- /dev/null +++ b/.github/workflows/nix-github-actions.yml @@ -0,0 +1,32 @@ +name: Nix Flake actions + +on: + pull_request: + push: + branches: + - 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 02a7a82..a7dcb1a 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,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": 1726447378, @@ -37,6 +57,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", + "nix-github-actions": "nix-github-actions", "nixpkgs": "nixpkgs" } }, diff --git a/flake.nix b/flake.nix index e1c1913..d0d38fa 100644 --- a/flake.nix +++ b/flake.nix @@ -4,10 +4,16 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; flake-utils.url = "github:numtide/flake-utils"; + nix-github-actions.url = "github:nix-community/nix-github-actions"; + nix-github-actions.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: + outputs = { self, nixpkgs, flake-utils, nix-github-actions }: + { + githubActions = nix-github-actions.lib.mkGithubMatrix { + checks = nixpkgs.lib.getAttrs [ "x86_64-linux" ] self.checks; + }; + } // flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; @@ -30,6 +36,8 @@ packages.default = self.packages.${system}.${packageName}; + checks.tailscale-manager = self.packages.${system}.tailscale-manager; + devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ haskellPackages.haskell-language-server # you must build it with your ghc to work