From 0803c6d22b54d216504a017887713def05f92eb4 Mon Sep 17 00:00:00 2001 From: "guillem.cordoba" Date: Tue, 5 Mar 2024 14:04:48 +0100 Subject: [PATCH] WIP --- nix/zome.nix | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/nix/zome.nix b/nix/zome.nix index 9525747..8037dfe 100644 --- a/nix/zome.nix +++ b/nix/zome.nix @@ -31,28 +31,34 @@ let pname = crate; doCheck = false; }; + optimizedWasm = stdenv.mkDerivation { + name = "${crate}-optimized"; + buildInputs = [ wasm binaryen ]; + phases = [ "buildPhase" ]; + buildPhase = '' + wasm-opt --strip-debug -Oz -o $out ${wasm}/lib/${crate}.wasm + ''; + }; in - if optimizeWasm then - stdenv.mkDerivation { - name = crate; - buildInputs = [ wasm binaryen ]; - phases = [ "buildPhase" ]; - buildPhase = '' - wasm-opt --strip-debug -Oz -o $out ${wasm}/lib/${crate}.wasm - ''; - meta = { - holochainPackageType = "zome"; - }; - } - else - stdenv.mkDerivation { - name = crate; - buildInputs = [ wasm ]; - phases = [ "buildPhase" ]; - buildPhase = '' - cp ${wasm}/lib/${crate}.wasm $out - ''; - meta = { - holochainPackageType = "zome"; + stdenv.mkDerivation { + name = crate; + buildInputs = [ optimizedWasm ]; + phases = [ "buildPhase" ]; + buildPhase = '' + cp ${wasm}/lib/${crate}.wasm $out + ''; + meta = { + holochainPackageType = "zome"; + debug = stdenv.mkDerivation { + name = "${crate}-debug"; + buildInputs = [ optimizedWasm ]; + phases = [ "buildPhase" ]; + buildPhase = '' + cp ${wasm}/lib/${crate}.wasm $out + ''; + meta = { + holochainPackageType = "zome"; + }; }; - } + }; + }