diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index e7feefa..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,13 +0,0 @@ -on: - push: - branches: - - main - pull_request: -jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: DeterminateSystems/nix-installer-action@main - - uses: actions/checkout@v4 - - run: nix flake check --keep-going - diff --git a/.github/workflows/nix-github-actions.yml b/.github/workflows/nix-github-actions.yml new file mode 100644 index 0000000..6d51ee3 --- /dev/null +++ b/.github/workflows/nix-github-actions.yml @@ -0,0 +1,39 @@ +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 + - run: | + sudo mkdir /nix + sudo chown "$USER" /nix + - uses: namespacelabs/nscloud-cache-action@v1 + with: + path: /nix + - uses: cachix/install-nix-action@v27 + - run: nix build -L '.#${{ matrix.attr }}' diff --git a/flake.lock b/flake.lock index a8e740f..63aa601 100644 --- a/flake.lock +++ b/flake.lock @@ -37,34 +37,38 @@ "type": "github" } }, - "nixpkgs": { + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1717555607, - "narHash": "sha256-WZ1s48OODmRJ3DHC+I/DtM3tDRuRJlNqMvxvAPTD7ec=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "0b8e7a1ae5a94da2e1ee3f3030a32020f6254105", + "lastModified": 1720066371, + "narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "622f829f5fe69310a866c8a6cd07e747c44ef820", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-24.05", - "repo": "nixpkgs", + "owner": "nix-community", + "repo": "nix-github-actions", "type": "github" } }, - "nixpkgs-amazon-ssm-agent": { + "nixpkgs": { "locked": { - "lastModified": 1717103298, - "narHash": "sha256-53QT7BSlhL3xNrKzkyzB8pjm/ZCdmpU1D06zhLrNg5s=", - "owner": "r-ryantm", + "lastModified": 1717555607, + "narHash": "sha256-WZ1s48OODmRJ3DHC+I/DtM3tDRuRJlNqMvxvAPTD7ec=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "a6a98862d0da89cc812fc4d0d8e5182c3671e4de", + "rev": "0b8e7a1ae5a94da2e1ee3f3030a32020f6254105", "type": "github" }, "original": { - "owner": "r-ryantm", - "ref": "auto-update/amazon-ssm-agent", + "owner": "nixos", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } @@ -124,8 +128,8 @@ }, "root": { "inputs": { + "nix-github-actions": "nix-github-actions", "nixpkgs": "nixpkgs", - "nixpkgs-amazon-ssm-agent": "nixpkgs-amazon-ssm-agent", "pre-commit-hooks": "pre-commit-hooks" } } diff --git a/flake.nix b/flake.nix index 896af34..e0d4277 100644 --- a/flake.nix +++ b/flake.nix @@ -1,13 +1,34 @@ { description = "NixOS Village AWS cloud"; - inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; - inputs.nixpkgs-amazon-ssm-agent.url = "github:r-ryantm/nixpkgs?ref=auto-update/amazon-ssm-agent"; - inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; + pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + nix-github-actions = { + url = "github:nix-community/nix-github-actions"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; - outputs = inputs@{ self, nixpkgs, pre-commit-hooks, ... }: { + outputs = inputs@{ self, nixpkgs, pre-commit-hooks, nix-github-actions, ... }: { lib.supportedSystems = [ "aarch64-darwin" "aarch64-linux" "x86_64-linux" ]; lib.forAllSystems = nixpkgs.lib.genAttrs self.lib.supportedSystems; + githubActions = nix-github-actions.lib.mkGithubMatrix { + inherit (self) checks; + platforms = { + x86_64-linux = [ + "nscloud-ubuntu-22.04-amd64-4x16-with-cache" + "nscloud-cache-size-20gb" + "nscloud-cache-tag-aarch64-linux" + ]; + aarch64-linux = [ + "nscloud-ubuntu-22.04-arm64-4x16-with-cache" + "nscloud-cache-size-20gb" + "nscloud-cache-tag-x86_64-linux" + ]; + }; + }; + devShells = self.lib.forAllSystems (system: { default = with nixpkgs.legacyPackages.${system}; mkShell { packages = [