NixOS / templates

Flake templates
MIT License
446 stars 81 forks source link

[Rust template] Clang error #85

Open Gau-thier opened 3 months ago

Gau-thier commented 3 months ago

Hi, thanks for these useful templates!

Unfortunately, the rust one can face the error: linking withccfailed: exit status: 1 error on Mac M1...

It worked perfectly, until I run cargo add sqlx then try to cargo build:

Compiling sqlx-macros v0.7.4
error: linking with `cc` failed: exit status: 1
[...]
  = note: ld: framework not found SystemConfiguration
          clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

error: could not compile `sqlx-macros` (lib) due to 1 previous error

I know this error is linked to clang but I don't find any way to solve it on my Mac M1... That would be great to have inside the template, the workaround to avoid any other Mac user to face this error.

I don't have any modifications on the flake.nix or the shell.nix generated and created by the template.

Cheers and thanks again!

Gau-thier commented 3 months ago

Finally found the solution, adding darwin.apple_sdk.frameworks.SystemConfiguration in the buildInputs because Apple machines need to brings frameworks into scope.

Should this be added in the template but in a commented line? Hence, one would be able to uncomment the line and solve this problem which will appear on all Apple machines running real world Rust.

tomberek commented 1 month ago

This can be added with a conditional. Something like this: https://github.com/NixOS/nixpkgs/blob/24d7835b9ae72ca8c553fc5c331342c1894a15b4/pkgs/by-name/nh/nh/package.nix#L34