devenv: Rust language can't link with Security framework on darwin

Describe the bug When compiling some rust code which requires openssl or other Security-related dependencies compilation fails with

  = note: ld: framework not found Security
          clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

To Reproduce https://gist.github.com/onsails/d2d33a63d88a5e7d656048bd5fa5a6b9.

Version

0.5

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16 (14 by maintainers)

Most upvoted comments

Figured out workaround:

              env.RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [
                openssl.dev
              ]) ++ (lib.optionals stdenv.isDarwin (with darwin.apple_sdk; [
                "-L${libiconv}/lib"
                "-L framework=${frameworks.Security}/Library/Frameworks"
              ]));

@domenkozar the problem lies with not running the setup-hooks (thanks to my naked shell change 😭 ). Especially problematic is the lack of NIX_CFLAGS_COMPILE env var. As this env var is used to pass down configurations to the Rust-underlying Clang (MacOS) / gcc (Linux) compiler. It’s a really hard problem though, as this means that we must run the setup-hooks if we want to get to feature parity with normal nix-shell. Will have to think about this.