diff --git a/.github/workflows/nix-github-actions.yml b/.github/workflows/nix-github-actions.yml new file mode 100644 index 0000000..bf3de13 --- /dev/null +++ b/.github/workflows/nix-github-actions.yml @@ -0,0 +1,32 @@ +name: Nix Flake actions + +on: + pull_request: + push: + +jobs: + nix-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v30 + - id: set-matrix + name: Generate Nix Matrix + run: | + set -Eeu + matrix="$(nix eval --json '.#githubActions.matrix')" + echo "matrix=$matrix" >> "$GITHUB_OUTPUT" + + nix-build: + name: ${{ matrix.name }} (${{ matrix.system }}) + needs: nix-matrix + runs-on: ${{ matrix.os }} + continue-on-error: true + strategy: + matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}} + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v30 + - run: nix build -L '.#${{ matrix.attr }}' diff --git a/Cargo.lock b/Cargo.lock index f4c756e..69964b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2028,7 +2028,7 @@ checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" [[package]] name = "provider" -version = "0.0.1" +version = "0.1.0" dependencies = [ "actix-service", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index c8e3103..1f9278f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "3" [workspace.package] -version = "0.0.1" +version = "0.1.0" authors = ["sparkzky", "Samuka007"] [workspace.metadata.crane] diff --git a/flake.lock b/flake.lock index 0c50838..9cede87 100644 --- a/flake.lock +++ b/flake.lock @@ -33,7 +33,39 @@ "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1737420293, + "narHash": "sha256-F1G5ifvqTpJq7fdkT34e/Jy9VCyzd5XfJ9TO8fHhJWE=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "f4158fa080ef4503c8f4c820967d946c2af31ec9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1688646010, + "narHash": "sha256-kCeza5eKI2NEi8k0EoeZfv3lN1r1Vwx+L/VA6I8tmG4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5daaa32204e9c46b05cd709218b7ba733d07e80c", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1739866667, "narHash": "sha256-EO1ygNKZlsAC9avfcwHkKGMsmipUk1Uc0TbrEZpkn64=", @@ -53,7 +85,8 @@ "inputs": { "crane": "crane", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", + "nix-github-actions": "nix-github-actions", + "nixpkgs": "nixpkgs_2", "rust-overlay": "rust-overlay" } }, diff --git a/flake.nix b/flake.nix index f53fe1a..6bcdfdd 100644 --- a/flake.nix +++ b/flake.nix @@ -5,13 +5,14 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; crane.url = "github:ipetkov/crane"; flake-utils.url = "github:numtide/flake-utils"; + nix-github-actions.url = "github:nix-community/nix-github-actions"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }: + outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, nix-github-actions, ... }: flake-utils.lib.eachDefaultSystem (system: let # reference: https://crane.dev/examples/quick-start-workspace.html @@ -32,12 +33,15 @@ strictDeps = true; # Add additional build inputs here buildInputs = with pkgs; [ + openssl + protobuf pkg-config ]; nativeBuildInputs = with pkgs; [ openssl protobuf + pkg-config ]; }; cargoArtifacts = craneLib.buildDepsOnly commonArgs; @@ -55,6 +59,8 @@ ./Cargo.lock (craneLib.fileset.commonCargoSources ./crates/app) (craneLib.fileset.commonCargoSources ./crates/service) + (craneLib.fileset.commonCargoSources ./crates/provider) + (craneLib.fileset.commonCargoSources ./crates/cni) (craneLib.fileset.commonCargoSources ./crates/my-workspace-hack) (craneLib.fileset.commonCargoSources crate) ]; @@ -140,5 +146,13 @@ ]; }; } - ); + ) + // { + githubActions = nix-github-actions.lib.mkGithubMatrix { + checks.x86_64-linux = self.checks.x86_64-linux; + checks.x86_64-darwin.faas-rs-crate = self.checks.x86_64-darwin.faas-rs-crate; + checks.aarch64-linux.faas-rs-crate = self.checks.aarch64-linux.faas-rs-crate; + checks.aarch64-darwin.faas-rs-crate = self.checks.aarch64-darwin.faas-rs-crate; + }; + }; }