diff --git a/nix/fixture/Cargo.toml b/nix/fixture/Cargo.toml index dd7a423..a1a0259 100644 --- a/nix/fixture/Cargo.toml +++ b/nix/fixture/Cargo.toml @@ -13,4 +13,4 @@ serde = "1" [profile.release] opt-level = "z" trim-paths = true -remap-debuginfo = true +# remap-debuginfo = true diff --git a/nix/fixture/flake.lock b/nix/fixture/flake.lock index b0f16cd..2cd548d 100644 --- a/nix/fixture/flake.lock +++ b/nix/fixture/flake.lock @@ -540,7 +540,7 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-Et0+O2at/RY/YGy59JJy2u9DZx4ealUUqqC88Ic62uA=", + "narHash": "sha256-0SyjUflu8VZMOKz7FK5VAACssNgJh70hJ5Zyo2qk5ho=", "path": "../..", "type": "path" }, diff --git a/nix/fixture/zome/src/lib.rs b/nix/fixture/zome/src/lib.rs index 7908d72..b9984e1 100644 --- a/nix/fixture/zome/src/lib.rs +++ b/nix/fixture/zome/src/lib.rs @@ -1,6 +1,5 @@ use hdk::prelude::*; - #[hdk_extern] pub fn hello(_: ()) -> ExternResult { Ok(String::from("hello")) diff --git a/nix/rustc-wrapper.sh b/nix/rustc-wrapper.sh new file mode 100755 index 0000000..e3aaf4e --- /dev/null +++ b/nix/rustc-wrapper.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +file="/build/source/zome/src/lib.rs" +# for arg in "$@"; do +# if [[ ${arg} == ${CARGO_HOME}/* && -z ${file} ]]; then +# file=${arg##${CARGO_HOME}} +# fi +# done +# echo "heyy" +# echo $file +args=() +for arg in "$@"; do + if [[ ${arg} == metadata=* ]]; then + args+=(metadata="${file}") + else + args+=("${arg}") + fi +done + +exec "${args[@]}" diff --git a/nix/zome.nix b/nix/zome.nix index 4ffa6b0..bf9b9fc 100644 --- a/nix/zome.nix +++ b/nix/zome.nix @@ -5,6 +5,7 @@ craneLib, workspacePath, crateCargoToml, + writeShellScript, excludedCrates }: @@ -14,12 +15,15 @@ let cargoToml = builtins.fromTOML (builtins.readFile crateCargoToml); crate = cargoToml.package.name; + # rustcWrapper = writeShellScript "rustc-wrapper.sh" (builtins.readFile ./rustc-wrapper.sh); + commonArgs = { strictDeps = true; doCheck = false; src = craneLib.cleanCargoSource (craneLib.path workspacePath); CARGO_BUILD_TARGET = "wasm32-unknown-unknown"; # CARGO_BUILD_RUSTFLAGS = ""; + # RUSTC_WRAPPER = rustcWrapper; }; wasmDeps = craneLib.buildDepsOnly (commonArgs // { @@ -32,6 +36,9 @@ let cargoLock = workspacePath + /Cargo.lock; cargoArtifacts = wasmDeps; cargoExtraArgs = "-p ${crate} --locked -v"; + # cargoBuildCommand = "cargo rustc --profile release -- -C metadata=${cratePath}/src/lib.rs"; + # cargoBuildCommand = "rustc -vv --crate-name ${crate} --edition=2021 ${workspacePath}/zome/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type cdylib --crate-type rlib --emit=dep-info,link -C opt-level=z -C embed-bitcode=no -Zunstable-options -Zremap-path-scope=all --remap-path-prefix=/build/source=. --out-dir /build/source/target/wasm32-unknown-unknown/release/deps --target wasm32-unknown-unknown -L dependency=/build/source/target/wasm32-unknown-unknown/release/deps -L dependency=/build/source/target/release/deps --extern hdk=/build/source/target/wasm32-unknown-unknown/release/deps/libhdk-958f0c3891df457c.rlib --extern serde=/build/source/target/wasm32-unknown-unknown/release/deps/libserde-7c4f086b3ce3ca72.rlib"; + # installPhaseCommand = ""; pname = crate; version = cargoToml.package.version; });