2

I've run into these issues a few times, and have yet to find a solution. My environment has Xcode Command-Line tools installed, but since installing Nix, Clang has been having a difficult time locating macOS SDK frameworks. I know these are present, as if I switch to a new user which has not had Nix installed, I'm able to build these without issue.

As an example,

{very long command invocation snipped}
/Users/paulcolusso/Developer/heartbeat/server2/target/debug/deps/libsqlx_macros-95911fe3462937f2.dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs"
  = note: ld: framework not found SystemConfiguration
          clang-11: error: linker command failed with exit code 1 (use -v to see invocation)


error: could not compile `sqlx-macros` due to previous error

I've discovered that the macOS SDK derivations do exist, such as the following from the nix discourse and adding darwin.apple_sdk.frameworks.SystemConfiguration derivation does indeed resolve the issue. The question How can I make macOS frameworks available to clang in a Nix environment? also touches on this.

That being said, it is a little time consuming to slowly add each framework, as needed. Is there a way to install the entire apple_sdk derivation into my home-manager or a nix-shell I can drop into? If not that, a way to escape out of the Nix sandbox without keeping another user account on hand?

pcolusso
  • 43
  • 1
  • 5
  • I don't think having a Nix installation should affect non-Nix programs' ability to find system files in any way. Maybe it's because of something specific to your installation. Perhaps someone in the Nix on macOS room can help: https://matrix.to/#/#macos:nixos.org – Robert Hensing Nov 08 '21 at 11:59

1 Answers1

3

Is there a way to install the entire apple_sdk derivation into my home-manager or a nix-shell I can drop into?

No/Yes. You could code something that collects all attrs and adds them or just copy them from https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/darwin/apple-sdk/frameworks.nix

If not that, a way to escape out of the Nix sandbox without keeping another user account on hand?

You can disable it with sandbox = false in nix.conf (https://nixos.org/manual/nix/stable/command-ref/conf-file.html#:~:text=Default%3A%20false-,sandbox,-If%20set%20to) but keep in mind that this is mostly untested and on linux some things only build in the sandbox.

SuperSandro2000
  • 581
  • 10
  • 20
  • "something that collects all attrs": in home-manager, `home.packages = with pkgs; [ ... ] ++ (builtins.attrValues darwin.apple_sdk.frameworks);` – Mike Placentra Apr 12 '23 at 17:13