From dd66417bd7214dc71db94d74550eaf37cb8aac37 Mon Sep 17 00:00:00 2001 From: Matt Carrier Date: Sat, 6 Jan 2024 17:45:42 -0800 Subject: [PATCH] build: add github action --- .github/workflows/nix-github-actions.yml | 45 ++++++++++++++++++++++++ flake.lock | 21 +++++++++++ flake.nix | 9 ++++- 3 files changed, 74 insertions(+), 1 deletion(-) 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..035c09c --- /dev/null +++ b/.github/workflows/nix-github-actions.yml @@ -0,0 +1,45 @@ +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 + - run: nix build + - run: ls result/www + - run: ls -la ./ + - run: git checkout gh-pages + - run: rm -fr www + - run: cp -r ./result/www www + - run: git commit -m "update build" + - run: git push -f origin gh-pages + # - run: nix-shell -p ghp-import + # - run: ghp-import --message "Automatic update from https://github.com/icecreammatt/wiki.net" ./result/www + # - run: git push --force origin gh-pages:gh-pages + + # matrix="$(nix eval --json '.#')" + # 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 ".#" diff --git a/flake.lock b/flake.lock index 737a991..c3241ce 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703863825, + "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1704194953, @@ -18,6 +38,7 @@ }, "root": { "inputs": { + "nix-github-actions": "nix-github-actions", "nixpkgs": "nixpkgs", "utils": "utils" } diff --git a/flake.nix b/flake.nix index 650ece3..8ad370e 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;