holochain / lair

secret lair private keystore
Apache License 2.0
42 stars 11 forks source link

Cannot provide libsodium without extra config #129

Open ThetaSinner opened 8 months ago

ThetaSinner commented 8 months ago

Currently the libsodium crate isn't building because there's a hash mismatch on the file its downloading. On its own that's a little concerning but it should be possible to provide a libsodium another way.

The following Nix shell hook should be enough to instruct libsodium-sys-stable to link against the libsodium that I'm providing

export SODIUM_LIB_DIR="${pkgs.libsodium}/lib/"
export SODIUM_SHARED="1"

Unfortunately, this fails with:

Caused by:
  process didn't exit successfully: `/home/thetasinner/source/projectname/target/debug/build/lair_keystore-523f875434d8fda4/build-script-build` (exit status: 127)
  --- stderr
  /home/thetasinner/source/projectname/target/debug/build/lair_keystore-523f875434d8fda4/build-script-build: error while loading shared libraries: libsodium.so.26: cannot open shared object file: No such file or directory
warning: build failed, waiting for other jobs to finish...

That means the build.rs for lair_keystore can't be compiled because it can't find the libsodium I'm asking it to link with. I don't fully get why but I'm assuming the build process for build scripts differs in some way to the way Cargo builds crates. Just depending on lair_keystore_api in my project works fine, but as soon as lair_keystore is pulled in it breaks... so I'm fairly sure I've configured everything right.

The only workaround for this I can find is to set export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SODIUM_LIB_DIR. That does work but it's requiring me to set something that is linker specific, outside the Cargo build process which is more likely to break than I'd like.

Is there any way the build dependency on lair_keystore_api from lair_keystore can be dropped to make this build configuration simpler?

ThetaSinner commented 8 months ago

The download seems to have been fixed now, that's good. Still think it's important to be able to configure the libsodium build through Lair