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

**URL:** <https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440>\
**Category:** Question\
**Created:** [November 22, 2019, 6:50pm UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440 "2019-11-22T18:50:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [November 22, 2019, 6:50pm UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/1 "2019-11-22T18:50:59Z")

</div>

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

```auto
= 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)

```

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [November 22, 2019, 9:20pm UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/2 "2019-11-22T21:20:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [November 23, 2019, 11:40am UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/3 "2019-11-23T11:40:07Z")

</div>

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

```auto
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";
}

```

---

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [November 23, 2019, 3:16pm UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/4 "2019-11-23T15:16:15Z")

</div>

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

BTW is `kcov` used at all?

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [November 27, 2019, 9:52am UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/5 "2019-11-27T09:52:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [November 27, 2019, 8:19pm UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/6 "2019-11-27T20:19:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [November 28, 2019, 10:30am UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/7 "2019-11-28T10:30:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [November 28, 2019, 5:14pm UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/8 "2019-11-28T17:14:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [November 28, 2019, 5:33pm UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/9 "2019-11-28T17:33:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [November 30, 2019, 12:53pm UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/10 "2019-11-30T12:53:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [November 30, 2019, 4:29pm UTC](https://discourse.pijul.org/t/solved-building-on-macos-with-the-provided-shell-nix/440/11 "2019-11-30T16:29:35Z")

</div>

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.
