From 9aa435914f35ffb71aaf50f58127a039a9bf443b Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 4 Apr 2023 16:07:31 -0700 Subject: [PATCH 01/14] fix(nix): Use wasi-sdk 12 to provide barretenberg-wasm in overlay --- barretenberg-wasm.nix | 41 +++++++++++++++++++++++++++++++++++++++++ flake.lock | 12 ++++++------ flake.nix | 3 ++- 3 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 barretenberg-wasm.nix diff --git a/barretenberg-wasm.nix b/barretenberg-wasm.nix new file mode 100644 index 0000000000..1265429087 --- /dev/null +++ b/barretenberg-wasm.nix @@ -0,0 +1,41 @@ +{ stdenv, cmake, ninja, binaryen, fetchzip }: +let + hostPlatform = stdenv.hostPlatform; + toolchain_file = ./cpp/cmake/toolchains/wasm32-wasi.cmake; + WASI_VERSION = "12"; + OS = if hostPlatform.isDarwin then "macos" else if hostPlatform.isLinux then "linux" else ""; + wasisdk = fetchzip { + url = "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION}.0-${OS}.tar.gz"; + sha256 = "sha256-zDlPPmH1mtpA66LZ8iS5AVZUWL5DY3v9YLs3qNN7y1U="; + }; +in +stdenv.mkDerivation +{ + pname = "barretenberg.wasm"; + version = "0.1.0"; + + src = ./cpp; + + nativeBuildInputs = [ cmake ninja binaryen ]; + + buildInputs = [ ]; + + cmakeFlags = [ + "-DTESTING=OFF" + "-DBENCHMARKS=OFF" + "-DCMAKE_TOOLCHAIN_FILE=${toolchain_file}" + "-DCMAKE_C_COMPILER=${wasisdk}/bin/clang" + "-DCMAKE_CXX_COMPILER=${wasisdk}/bin/clang++" + "-DCMAKE_AR=${wasisdk}/bin/llvm-ar" + "-DCMAKE_RANLIB=${wasisdk}/bin/llvm-ranlib" + "-DCMAKE_SYSROOT=${wasisdk}/share/wasi-sysroot" + "-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER" + "-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY" + "-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY" + "-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY" + "-DCMAKE_C_COMPILER_WORKS=ON" + "-DCMAKE_CXX_COMPILER_WORKS=ON" + ]; + + enableParallelBuilding = true; +} diff --git a/flake.lock b/flake.lock index 4128dfe7e3..d0e2bfe5ce 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", "owner": "numtide", "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", "type": "github" }, "original": { @@ -17,11 +17,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1678230755, - "narHash": "sha256-SFAXgNjNTXzcAideXcP0takfUGVft/VR5CACmYHg+Fc=", + "lastModified": 1680498889, + "narHash": "sha256-4nGFBm+oILOO6DPoKTPxVlfkZSxCOY4W25zSRHESK48=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a7cc81913bb3cd1ef05ed0ece048b773e1839e51", + "rev": "799d153e4f316143a9db0eb869ecf44d8d4c0356", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 1d4dd4d753..6b6b05f0ec 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,7 @@ barretenberg = super.callPackage ./barretenberg.nix { llvmPackages = self.llvmPackages_12; }; + barretenberg-wasm = super.callPackage ./barretenberg-wasm.nix { }; }; in flake-utils.lib.eachDefaultSystem @@ -63,7 +64,7 @@ llvm14 = pkgs.barretenberg.override { llvmPackages = pkgs.llvmPackages_14; }; - wasm32 = pkgs.pkgsCross.wasi32.barretenberg; + wasm32 = pkgs.barretenberg-wasm; # Defaulting to llvm12 so we can ensure consistent shells default = packages.llvm12; From 77c94f604e3630a7f15eeeb3b7934022d10b2ea5 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 4 Apr 2023 16:35:05 -0700 Subject: [PATCH 02/14] chore: Remove the wasm stuff from main package --- barretenberg.nix | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/barretenberg.nix b/barretenberg.nix index fc00242f4a..be2fd7c8b8 100644 --- a/barretenberg.nix +++ b/barretenberg.nix @@ -1,4 +1,4 @@ -{ overrideCC, stdenv, llvmPackages, cmake, ninja, lib, callPackage, binaryen, gcc11 }: +{ overrideCC, stdenv, llvmPackages, cmake, ninja, lib, callPackage, gcc11 }: let targetPlatform = stdenv.targetPlatform; buildEnv = @@ -18,21 +18,16 @@ buildEnv.mkDerivation src = ./cpp; - nativeBuildInputs = [ cmake ninja ] - ++ optionals targetPlatform.isWasm [ binaryen ]; + nativeBuildInputs = [ cmake ninja ]; - buildInputs = [ ] - ++ optionals (targetPlatform.isDarwin || targetPlatform.isLinux) [ - llvmPackages.openmp - ]; + buildInputs = [ llvmPackages.openmp ]; cmakeFlags = [ "-DTESTING=OFF" "-DBENCHMARKS=OFF" "-DCMAKE_TOOLCHAIN_FILE=${toolchain_file}" - ] - ++ optionals (targetPlatform.isDarwin || targetPlatform.isLinux) - [ "-DCMAKE_BUILD_TYPE=RelWithAssert" ]; + "-DCMAKE_BUILD_TYPE=RelWithAssert" + ]; NIX_CFLAGS_COMPILE = optionals targetPlatform.isDarwin [ " -fno-aligned-allocation" ]; From 8f47886eb6cf4b1104c23fe957a4a1703a0070c0 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 4 Apr 2023 16:38:07 -0700 Subject: [PATCH 03/14] chore(nix): Switch the default llvm to 11 --- flake.nix | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index 6b6b05f0ec..100ae50aa3 100644 --- a/flake.nix +++ b/flake.nix @@ -10,10 +10,7 @@ outputs = { self, nixpkgs, flake-utils }: let barretenbergOverlay = self: super: { - # It seems that llvmPackages_11 can't build WASI, so default to llvmPackages_12 - barretenberg = super.callPackage ./barretenberg.nix { - llvmPackages = self.llvmPackages_12; - }; + barretenberg = super.callPackage ./barretenberg.nix { }; barretenberg-wasm = super.callPackage ./barretenberg-wasm.nix { }; }; in @@ -34,10 +31,7 @@ value = pkgs.pkgsCross.aarch64-multiplatform-musl.pkgsLLVM.barretenberg; } ++ optional (pkgs.hostPlatform.isx86_64 && pkgs.hostPlatform.isDarwin) { name = "cross-aarch64"; - value = pkgs.pkgsCross.aarch64-darwin.barretenberg.override { - # llvmPackages_12 seems to fail when we try to cross-compile but llvmPackages_11 works - llvmPackages = pkgs.llvmPackages_11; - }; + value = pkgs.pkgsCross.aarch64-darwin.barretenberg; } ); @@ -54,10 +48,10 @@ in rec { packages = { - llvm11 = pkgs.barretenberg.override { - llvmPackages = pkgs.llvmPackages_11; + llvm11 = pkgs.barretenberg; + llvm12 = pkgs.barretenberg.override { + llvmPackages = pkgs.llvmPackages_12; }; - llvm12 = pkgs.barretenberg; llvm13 = pkgs.barretenberg.override { llvmPackages = pkgs.llvmPackages_13; }; @@ -66,8 +60,7 @@ }; wasm32 = pkgs.barretenberg-wasm; - # Defaulting to llvm12 so we can ensure consistent shells - default = packages.llvm12; + default = packages.llvm11; } // crossTargets; # Provide legacyPackages with our overlay so we can run @@ -88,6 +81,7 @@ wasm32 = pkgs.mkShell.override { + # TODO: This derivations forces wasi-sdk 12 so the stdenv will have the wrong tools stdenv = packages.wasm32.stdenv; } ({ From 8b8887cce6f49beae26636e1352f4abc6c7f73de Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 4 Apr 2023 16:49:43 -0700 Subject: [PATCH 04/14] chore(nix): Add transcript00 to the overlay chore(nix): Cleanup for nix flake check --- flake.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 100ae50aa3..1d34c0fb70 100644 --- a/flake.nix +++ b/flake.nix @@ -9,9 +9,13 @@ outputs = { self, nixpkgs, flake-utils }: let - barretenbergOverlay = self: super: { - barretenberg = super.callPackage ./barretenberg.nix { }; - barretenberg-wasm = super.callPackage ./barretenberg-wasm.nix { }; + barretenbergOverlay = final: prev: { + barretenberg = prev.callPackage ./barretenberg.nix { }; + barretenberg-wasm = prev.callPackage ./barretenberg-wasm.nix { }; + barretenberg-transcript00 = prev.fetchurl { + url = "http://aztec-ignition.s3.amazonaws.com/MAIN%20IGNITION/monomial/transcript00.dat"; + sha256 = "sha256-D5SzlCb1pX0aF3QmJPfTFwoy4Z1sXhbyAigUOdvkhpU="; + }; }; in flake-utils.lib.eachDefaultSystem From 3f4b71750f1ef83439bb1de13c34a46db64999ea Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 4 Apr 2023 17:05:02 -0700 Subject: [PATCH 05/14] Use hash for each platform --- barretenberg-wasm.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/barretenberg-wasm.nix b/barretenberg-wasm.nix index 1265429087..d67ac0fb45 100644 --- a/barretenberg-wasm.nix +++ b/barretenberg-wasm.nix @@ -4,9 +4,10 @@ let toolchain_file = ./cpp/cmake/toolchains/wasm32-wasi.cmake; WASI_VERSION = "12"; OS = if hostPlatform.isDarwin then "macos" else if hostPlatform.isLinux then "linux" else ""; + HASH = if hostPlatform.isDarwin then "sha256-zDlPPmH1mtpA66LZ8iS5AVZUWL5DY3v9YLs3qNN7y1U=" else if hostPlatform.isLinux then "sha256-ctDMbtbjFGwRbudp+eONU912trHtI1gyQVtBCmFeIFw=" else ""; wasisdk = fetchzip { url = "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION}.0-${OS}.tar.gz"; - sha256 = "sha256-zDlPPmH1mtpA66LZ8iS5AVZUWL5DY3v9YLs3qNN7y1U="; + sha256 = HASH; }; in stdenv.mkDerivation From b11c5bf355f6319a5112bfe76bac3e535a0e3a57 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 4 Apr 2023 17:11:29 -0700 Subject: [PATCH 06/14] avoid symlinks --- barretenberg-wasm.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg-wasm.nix b/barretenberg-wasm.nix index d67ac0fb45..228292f5de 100644 --- a/barretenberg-wasm.nix +++ b/barretenberg-wasm.nix @@ -25,8 +25,8 @@ stdenv.mkDerivation "-DTESTING=OFF" "-DBENCHMARKS=OFF" "-DCMAKE_TOOLCHAIN_FILE=${toolchain_file}" - "-DCMAKE_C_COMPILER=${wasisdk}/bin/clang" - "-DCMAKE_CXX_COMPILER=${wasisdk}/bin/clang++" + "-DCMAKE_C_COMPILER=${wasisdk}/bin/clang-11" + "-DCMAKE_CXX_COMPILER=${wasisdk}/bin/clang-11" "-DCMAKE_AR=${wasisdk}/bin/llvm-ar" "-DCMAKE_RANLIB=${wasisdk}/bin/llvm-ranlib" "-DCMAKE_SYSROOT=${wasisdk}/share/wasi-sysroot" From 9cd2417997ce1f44ece2696e617f44c92f8a5871 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 5 Apr 2023 08:28:17 -0700 Subject: [PATCH 07/14] try wasi-sdk that someone wrote on github --- barretenberg-wasm.nix | 23 +++++++------------ wasi-sdk.nix | 51 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 wasi-sdk.nix diff --git a/barretenberg-wasm.nix b/barretenberg-wasm.nix index 228292f5de..5c176576e3 100644 --- a/barretenberg-wasm.nix +++ b/barretenberg-wasm.nix @@ -1,14 +1,7 @@ -{ stdenv, cmake, ninja, binaryen, fetchzip }: +{ stdenv, cmake, ninja, binaryen, callPackage }: let - hostPlatform = stdenv.hostPlatform; toolchain_file = ./cpp/cmake/toolchains/wasm32-wasi.cmake; - WASI_VERSION = "12"; - OS = if hostPlatform.isDarwin then "macos" else if hostPlatform.isLinux then "linux" else ""; - HASH = if hostPlatform.isDarwin then "sha256-zDlPPmH1mtpA66LZ8iS5AVZUWL5DY3v9YLs3qNN7y1U=" else if hostPlatform.isLinux then "sha256-ctDMbtbjFGwRbudp+eONU912trHtI1gyQVtBCmFeIFw=" else ""; - wasisdk = fetchzip { - url = "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION}.0-${OS}.tar.gz"; - sha256 = HASH; - }; + wasi-sdk = callPackage ./wasi-sdk.nix { }; in stdenv.mkDerivation { @@ -17,7 +10,7 @@ stdenv.mkDerivation src = ./cpp; - nativeBuildInputs = [ cmake ninja binaryen ]; + nativeBuildInputs = [ cmake ninja binaryen wasi-sdk ]; buildInputs = [ ]; @@ -25,11 +18,11 @@ stdenv.mkDerivation "-DTESTING=OFF" "-DBENCHMARKS=OFF" "-DCMAKE_TOOLCHAIN_FILE=${toolchain_file}" - "-DCMAKE_C_COMPILER=${wasisdk}/bin/clang-11" - "-DCMAKE_CXX_COMPILER=${wasisdk}/bin/clang-11" - "-DCMAKE_AR=${wasisdk}/bin/llvm-ar" - "-DCMAKE_RANLIB=${wasisdk}/bin/llvm-ranlib" - "-DCMAKE_SYSROOT=${wasisdk}/share/wasi-sysroot" + "-DCMAKE_C_COMPILER=${wasi-sdk}/bin/clang" + "-DCMAKE_CXX_COMPILER=${wasi-sdk}/bin/clang++" + "-DCMAKE_AR=${wasi-sdk}/bin/llvm-ar" + "-DCMAKE_RANLIB=${wasi-sdk}/bin/llvm-ranlib" + "-DCMAKE_SYSROOT=${wasi-sdk}/share/wasi-sysroot" "-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER" "-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY" "-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY" diff --git a/wasi-sdk.nix b/wasi-sdk.nix new file mode 100644 index 0000000000..8cca58c585 --- /dev/null +++ b/wasi-sdk.nix @@ -0,0 +1,51 @@ +# https://github.com/ereslibre/nixities/blob/2c60af777fc863f90e6e4eeffcf3465def93a1f3/packages/wasi-sdk/default.nix +{ lib, pkgs, stdenv }: +let + pname = "wasi-sdk"; + version = "12"; +in +pkgs.stdenv.mkDerivation { + inherit pname version; + + sourceRoot = "${pname}-${version}.0"; + dontBuild = true; + dontConfigure = true; + dontStrip = true; + + nativeBuildInputs = + lib.optional stdenv.isLinux (with pkgs; [ autoPatchelfHook ]); + + installPhase = '' + mkdir -p $out/{bin,lib,share} + mv bin/* $out/bin/ + mv lib/* $out/lib/ + mv share/* $out/share/ + ''; + + src = + let + mapSystem = system: + if system == "x86_64-linux" then { + tarballSuffix = "linux"; + hash = "sha256-ctDMbtbjFGwRbudp+eONU912trHtI1gyQVtBCmFeIFw="; + } else { + tarballSuffix = "macos"; + hash = "sha256-juJfnD/eYY/upcV62tOFFSYmeEtra1L7Vj5e2DK/U+8="; + }; + in + (if builtins.elem stdenv.hostPlatform.system [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ] then + let system = mapSystem stdenv.hostPlatform.system; + in pkgs.fetchurl { + url = + "https://github.com/WebAssembly/${pname}/releases/download/${pname}-${version}/${pname}-${version}.0-${system.tarballSuffix}.tar.gz"; + hash = system.hash; + } + else + throw "unsupported system"); + + meta = { platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; }; +} From 36af9b7b09382a0494346f5813bef69880736a7b Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 5 Apr 2023 08:29:54 -0700 Subject: [PATCH 08/14] fix hash for linux --- wasi-sdk.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wasi-sdk.nix b/wasi-sdk.nix index 8cca58c585..00a79ec6f6 100644 --- a/wasi-sdk.nix +++ b/wasi-sdk.nix @@ -27,7 +27,7 @@ pkgs.stdenv.mkDerivation { mapSystem = system: if system == "x86_64-linux" then { tarballSuffix = "linux"; - hash = "sha256-ctDMbtbjFGwRbudp+eONU912trHtI1gyQVtBCmFeIFw="; + hash = "sha256-+kdpTXW/b86Y++eScZMpiyXuA9reJ/ykU9fdUwN4lzo="; } else { tarballSuffix = "macos"; hash = "sha256-juJfnD/eYY/upcV62tOFFSYmeEtra1L7Vj5e2DK/U+8="; From b6011a3210fc8ca3b396edad2e40def2523fb1cd Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 5 Apr 2023 09:10:00 -0700 Subject: [PATCH 09/14] try to ignore libstdc++ --- wasi-sdk.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wasi-sdk.nix b/wasi-sdk.nix index 00a79ec6f6..742a0db893 100644 --- a/wasi-sdk.nix +++ b/wasi-sdk.nix @@ -12,6 +12,8 @@ pkgs.stdenv.mkDerivation { dontConfigure = true; dontStrip = true; + autoPatchelfIgnoreMissingDeps = [ "libstdc++" ]; + nativeBuildInputs = lib.optional stdenv.isLinux (with pkgs; [ autoPatchelfHook ]); From bfa271eec7a619ee0785cfee929d27785d75a2b3 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 5 Apr 2023 09:12:19 -0700 Subject: [PATCH 10/14] need the whole name --- wasi-sdk.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wasi-sdk.nix b/wasi-sdk.nix index 742a0db893..1bf53843bd 100644 --- a/wasi-sdk.nix +++ b/wasi-sdk.nix @@ -12,7 +12,7 @@ pkgs.stdenv.mkDerivation { dontConfigure = true; dontStrip = true; - autoPatchelfIgnoreMissingDeps = [ "libstdc++" ]; + autoPatchelfIgnoreMissingDeps = [ "libstdc++.so.6" ]; nativeBuildInputs = lib.optional stdenv.isLinux (with pkgs; [ autoPatchelfHook ]); From 05ad1ec5f1e2d803ff22aa4efb7657b62555f1c1 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 5 Apr 2023 09:24:00 -0700 Subject: [PATCH 11/14] try to include std lib instead of ignore --- wasi-sdk.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wasi-sdk.nix b/wasi-sdk.nix index 1bf53843bd..eb1ddddbce 100644 --- a/wasi-sdk.nix +++ b/wasi-sdk.nix @@ -12,11 +12,14 @@ pkgs.stdenv.mkDerivation { dontConfigure = true; dontStrip = true; - autoPatchelfIgnoreMissingDeps = [ "libstdc++.so.6" ]; + # autoPatchelfIgnoreMissingDeps = [ "libstdc++.so.6" ]; nativeBuildInputs = lib.optional stdenv.isLinux (with pkgs; [ autoPatchelfHook ]); + buildInputs = + lib.optional stdenv.isLinux [ stdenv.cc.cc.lib ]; + installPhase = '' mkdir -p $out/{bin,lib,share} mv bin/* $out/bin/ From e7b02d0624f64e77bd5aa4c9498cc899004b0f30 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 5 Apr 2023 09:48:22 -0700 Subject: [PATCH 12/14] cleanup and nix flake check --- wasi-sdk.nix | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/wasi-sdk.nix b/wasi-sdk.nix index eb1ddddbce..c630054ba4 100644 --- a/wasi-sdk.nix +++ b/wasi-sdk.nix @@ -1,4 +1,5 @@ -# https://github.com/ereslibre/nixities/blob/2c60af777fc863f90e6e4eeffcf3465def93a1f3/packages/wasi-sdk/default.nix +# Copied from https://github.com/ereslibre/nixities/blob/2c60af777fc863f90e6e4eeffcf3465def93a1f3/packages/wasi-sdk/default.nix +# with a fix for the autoPatchelfHook needing libstdc++.so and some refactor { lib, pkgs, stdenv }: let pname = "wasi-sdk"; @@ -12,11 +13,11 @@ pkgs.stdenv.mkDerivation { dontConfigure = true; dontStrip = true; - # autoPatchelfIgnoreMissingDeps = [ "libstdc++.so.6" ]; - nativeBuildInputs = lib.optional stdenv.isLinux (with pkgs; [ autoPatchelfHook ]); + # Needed by autoPatchelfHook to have libstdc++ + # see https://discourse.nixos.org/t/autopatchelfhook-not-patching-all-dependencies/14634/6 buildInputs = lib.optional stdenv.isLinux [ stdenv.cc.cc.lib ]; @@ -29,28 +30,19 @@ pkgs.stdenv.mkDerivation { src = let - mapSystem = system: - if system == "x86_64-linux" then { - tarballSuffix = "linux"; - hash = "sha256-+kdpTXW/b86Y++eScZMpiyXuA9reJ/ykU9fdUwN4lzo="; - } else { - tarballSuffix = "macos"; + tarball = + if stdenv.hostPlatform.isDarwin then { + suffix = "macos"; hash = "sha256-juJfnD/eYY/upcV62tOFFSYmeEtra1L7Vj5e2DK/U+8="; + } else { + suffix = "linux"; + hash = "sha256-+kdpTXW/b86Y++eScZMpiyXuA9reJ/ykU9fdUwN4lzo="; }; in - (if builtins.elem stdenv.hostPlatform.system [ - "x86_64-linux" - "x86_64-darwin" - "aarch64-darwin" - ] then - let system = mapSystem stdenv.hostPlatform.system; - in pkgs.fetchurl { - url = - "https://github.com/WebAssembly/${pname}/releases/download/${pname}-${version}/${pname}-${version}.0-${system.tarballSuffix}.tar.gz"; - hash = system.hash; - } - else - throw "unsupported system"); - meta = { platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; }; + pkgs.fetchurl { + url = + "https://github.com/WebAssembly/${pname}/releases/download/${pname}-${version}/${pname}-${version}.0-${tarball.suffix}.tar.gz"; + hash = tarball.hash; + }; } From 1159aa29ab2fa0c2fccfa7d74b5d495e3a359adf Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 5 Apr 2023 10:40:03 -0700 Subject: [PATCH 13/14] chore(ci): Check the nix flake in CI --- .github/workflows/nix.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index dd76e8301c..2c0d71a4b4 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -32,6 +32,10 @@ jobs: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Check nix flake + run: | + nix flake check + - name: Build barretenberg as ${{ matrix.target }} run: | nix build -L .#${{ matrix.target }} From 12957ac689d77430ecab2ad13ab56b52e24d5040 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 5 Apr 2023 11:51:41 -0700 Subject: [PATCH 14/14] run default build instead of llvm12 --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 2c0d71a4b4..91da25315c 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -21,7 +21,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - target: [llvm12, wasm32, cross-aarch64] + target: [default, wasm32, cross-aarch64] steps: - name: Checkout