Skip to content

Commit

Permalink
Add support for MacOS build on Nix (#74)
Browse files Browse the repository at this point in the history
* Add support for MacOS build on Nix

* Add Apple libraries into nix develop shell

* Try to fix Cairo Nix build

* Remove unneeded changes
  • Loading branch information
soareschen authored Sep 7, 2024
1 parent 2c5758e commit 1309b2c
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 8 deletions.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: MacOS Build
on:
pull_request: {}
push:
tags:
- v[0-9]+.*
branches:
- "release/*"
- main

jobs:
test-contracts:
name: Build MacOS Nix dependencies
runs-on: macos-14
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@V27
with:
extra_nix_config: |
experimental-features = nix-command flakes
- uses: cachix/cachix-action@v15
with:
name: ibc-starknet
extraPullNames: hermes-sdk,cosmos-nix
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Run Nix build
run: |
sudo rm -rf /opt/homebrew
nix develop -c true
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@

tools = {
inherit (nixpkgs)
pkg-config
protobuf
cargo-nextest
taplo
Expand All @@ -118,7 +117,12 @@
nixfmt = nixpkgs.nixfmt-rfc-style;
};

shell-deps = (builtins.attrValues starknet-pkgs) ++ (builtins.attrValues tools);
mac-deps = nixpkgs.lib.optional nixpkgs.stdenv.isDarwin [
nixpkgs.libiconv
nixpkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];

shell-deps = (builtins.attrValues starknet-pkgs) ++ (builtins.attrValues tools) ++ mac-deps;
in
{
packages = {
Expand Down
8 changes: 7 additions & 1 deletion nix/cairo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ let
OPENSSL_NO_VENDOR = 1;
PKG_CONFIG_PATH = "${nixpkgs.openssl.dev}/lib/pkgconfig";

nativeBuildInputs = [ nixpkgs.pkg-config ];
nativeBuildInputs = [
nixpkgs.pkg-config
];

buildInputs = nixpkgs.lib.optionals nixpkgs.stdenv.isDarwin [
nixpkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];
};
in
cairo
4 changes: 4 additions & 0 deletions nix/scarb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ let
cargoHash = "sha256-cAEwCX1zGJu4+ufdVSqBbksa1FLZWVNt2TLZ5JlGISk=";

SCARB_CORELIB_LOCAL_PATH = cairo-src + "/corelib";

buildInputs = nixpkgs.lib.optionals nixpkgs.stdenv.isDarwin [
nixpkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];
};
in
cairo
6 changes: 5 additions & 1 deletion nix/snforge.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ let
};
};

doCheck = false;

OPENSSL_NO_VENDOR = 1;
PKG_CONFIG_PATH = "${nixpkgs.openssl.dev}/lib/pkgconfig";

nativeBuildInputs = [ nixpkgs.pkg-config ];

doCheck = false;
buildInputs = nixpkgs.lib.optionals nixpkgs.stdenv.isDarwin [
nixpkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];
};
in
snforge
6 changes: 5 additions & 1 deletion nix/starknet-devnet.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ let
lockFile = starknet-devnet-src + "/Cargo.lock";
};

doCheck = false;

OPENSSL_NO_VENDOR = 1;
PKG_CONFIG_PATH = "${nixpkgs.openssl.dev}/lib/pkgconfig";

nativeBuildInputs = [ nixpkgs.pkg-config ];

doCheck = false;
buildInputs = nixpkgs.lib.optionals nixpkgs.stdenv.isDarwin [
nixpkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];
};
in
starknet-devnet

0 comments on commit 1309b2c

Please sign in to comment.