Pijul

[Solved] Building on macOS with the provided shell.nix

Has anyone being able to build on macOS using Nix? I added CoreServices, Security and amp to buildInputs but I still get

= note: ld: library not found for -lgmp
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error

error: could not compile `pijul`.

Caused by:
  process didn't exit successfully: `rustc --crate-name pijul pijul/src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=a1718cb75ee9a8ab -C extra-filename=-a1718cb75ee9a8ab --out-dir /Users/tae/Projects/pijul/target/debug/deps -C incremental=/Users/tae/Projects/pijul/target/debug/incremental -L dependency=/Users/tae/Projects/pijul/target/debug/deps --extern atty=/Users/tae/Projects/pijul/target/debug/deps/libatty-26b6fa8791b98199.rlib --extern base64=/Users/tae/Projects/pijul/target/debug/deps/libbase64-b220d3eb6f2ffa57.rlib --extern bincode=/Users/tae/Projects/pijul/target/debug/deps/libbincode-484d00f169aeeba5.rlib --extern bs58=/Users/tae/Projects/pijul/target/debug/deps/libbs58-97f1ebf697388b3a.rlib --extern chrono=/Users/tae/Projects/pijul/target/debug/deps/libchrono-c857a75905fb5e30.rlib --extern clap=/Users/tae/Projects/pijul/target/debug/deps/libclap-2aebdb47a86a6e8e.rlib --extern cryptovec=/Users/tae/Projects/pijul/target/debug/deps/libcryptovec-4637813889290493.rlib --extern dirs=/Users/tae/Projects/pijul/target/debug/deps/libdirs-f93900930fff7174.rlib --extern env_logger=/Users/tae/Projects/pijul/target/debug/deps/libenv_logger-8b765db27d7574fa.rlib --extern failure=/Users/tae/Projects/pijul/target/debug/deps/libfailure-ffff1950151ec041.rlib --extern flate2=/Users/tae/Projects/pijul/target/debug/deps/libflate2-96b25325bfa872cb.rlib --extern futures=/Users/tae/Projects/pijul/target/debug/deps/libfutures-704c6801755c6731.rlib --extern getch=/Users/tae/Projects/pijul/target/debug/deps/libgetch-a04bf3a2270caa7e.rlib --extern hex=/Users/tae/Projects/pijul/target/debug/deps/libhex-ac53f1124fd15d02.rlib --extern ignore=/Users/tae/Projects/pijul/target/debug/deps/libignore-5b44be1fc02467f7.rlib --extern libpijul=/Users/tae/Projects/pijul/target/debug/deps/liblibpijul-9b17ce09a508d56b.rlib --extern line=/Users/tae/Projects/pijul/target/debug/deps/libline-3d6cd069b505d3e5.rlib --extern log=/Users/tae/Projects/pijul/target/debug/deps/liblog-cdf778e56b153fb6.rlib --extern pathdiff=/Users/tae/Projects/pijul/target/debug/deps/libpathdiff-8075773b244e861d.rlib --extern progrs=/Users/tae/Projects/pijul/target/debug/deps/libprogrs-503da0cecdbca852.rlib --extern rand=/Users/tae/Projects/pijul/target/debug/deps/librand-4fac10097396b9f6.rlib --extern regex=/Users/tae/Projects/pijul/target/debug/deps/libregex-84708eb260755314.rlib --extern reqwest=/Users/tae/Projects/pijul/target/debug/deps/libreqwest-7015e72b17b67ed1.rlib --extern rpassword=/Users/tae/Projects/pijul/target/debug/deps/librpassword-30b5e24f270a5261.rlib --extern sequoia_openpgp=/Users/tae/Projects/pijul/target/debug/deps/libsequoia_openpgp-9b27c19d18e46e14.rlib --extern serde=/Users/tae/Projects/pijul/target/debug/deps/libserde-8939373cf212047c.rlib --extern serde_derive=/Users/tae/Projects/pijul/target/debug/deps/libserde_derive-8e3e033bc99e2aa6.dylib --extern shell_escape=/Users/tae/Projects/pijul/target/debug/deps/libshell_escape-1212dadfb7224aba.rlib --extern tar=/Users/tae/Projects/pijul/target/debug/deps/libtar-6b9addcb8da12f18.rlib --extern tempfile=/Users/tae/Projects/pijul/target/debug/deps/libtempfile-fd366fa2b2d4819a.rlib --extern term=/Users/tae/Projects/pijul/target/debug/deps/libterm-eeeb6c4745cb2e8f.rlib --extern thrussh=/Users/tae/Projects/pijul/target/debug/deps/libthrussh-8fb501342790e5ca.rlib --extern thrussh_config=/Users/tae/Projects/pijul/target/debug/deps/libthrussh_config-71796875d250b6aa.rlib --extern thrussh_keys=/Users/tae/Projects/pijul/target/debug/deps/libthrussh_keys-273f964c57bec87a.rlib --extern tokio=/Users/tae/Projects/pijul/target/debug/deps/libtokio-991705a57548e55e.rlib --extern tokio_uds=/Users/tae/Projects/pijul/target/debug/deps/libtokio_uds-99638a49674c1ef7.rlib --extern toml=/Users/tae/Projects/pijul/target/debug/deps/libtoml-d760e713a55938fe.rlib --extern username=/Users/tae/Projects/pijul/target/debug/deps/libusername-fc5004d8ca506b8e.rlib -L native=/Users/tae/Projects/pijul/target/debug/build/miniz-sys-068bd55f076c673b/out -L native=/nix/store/fp4lds848d94dza193vvfbhn4mkagp6a-openssl-1.1.1d/lib -L native=/Users/tae/Projects/pijul/target/debug/build/bzip2-sys-1d3ca3f7b3880c19/out/lib -L native=/nix/store/3a06bgkw6nr8i7jxv7wywy752lfrv19l-nettle-3.5.1/lib -L native=/nix/store/3a06bgkw6nr8i7jxv7wywy752lfrv19l-nettle-3.5.1/lib -L native=/nix/store/3fd9xlm4nhb1k192qrswir39sqgmwrf5-libsodium-1.0.18/lib` (exitcode: 1)

Totally Nettle! Have you tried adding “gmp” to the buildInputs in shell.nix?

Yes, there’s a type in my original post. I also removed kcov because there’s at least one dependency that currently doesn’t build on macOS (but I think it should, my plan it to fix that later). Here is what I’m trying

with import <nixpkgs> {};
with pkgs.darwin.apple_sdk.frameworks;

let src = fetchFromGitHub {
      owner = "mozilla";
      repo = "nixpkgs-mozilla";
      rev = "e37160aaf4de5c4968378e7ce6fe5212f4be239f";
      sha256 = "013hapfp76s87wiwyc02mzq1mbva2akqxyh37p27ngqiz0kq5f2n";
   };
in
with import "${src.out}/rust-overlay.nix" pkgs pkgs;

clangStdenv.mkDerivation {
  name = "rust-pijul";
  buildInputs = [
    CoreServices Security
    gmp
    rustChannels.stable.rust
    parallel
    python3Packages.httpserver
    libsodium pkgconfig openssl nettle
  ];
  LIBCLANG_PATH="${llvmPackages.libclang}/lib";
}

Turns out the reason I couldn’t build was that I wan’t using a --pure shell.

BTW is kcov used at all?

Congrats! kcov is used to check test coverage, if you just want to build, develop and install Pijul you should be ok without it.

Yeah, I already started to play around, but my plan is also to fix kcov on macOS and send a patch with a multi-platform shell.nix file

Oh, by the way, kcov is not LLVM-specific and is therefore really slow (on Rust, but maybe also on other languages). It seems there are better things now, which weren’t around when we started looking at coverage.

Do you have any alternative on mind? I plan to work on this next Saturday

Yes, it’s called LCOV, and there’s a related thing called grcov.

No problem at all with lcov on macOS. Do you wan’t me to try something? I’m pretty new and because I cannot install kcov I cannot compare their output

You can of course try to produce coverage reports when running the BATS tests, that’s what kcov does. You might need to modify some things in the tests helper files.