Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nix build on OSX #1340

Merged
merged 1 commit into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion nix/overlays/wire-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ self: super: {
sha256 = "1i9dlhw0xk1viglyhail9fb36v1awrypps8jmhrkz8k1bhx98ci3";
};
cargoSha256 = "0zs8ibv7rinrrzp9naxd7yak7kn1gp3pjb3g8i4wf7xw2hkkq81z";

patchLibs = super.lib.optionalString super.stdenv.isDarwin ''
install_name_tool -id $out/lib/libcryptobox.dylib $out/lib/libcryptobox.dylib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this was absolutely needed? I thought it fixed itself by just bumping nixpkgs no?

The fact that buildRustPackage outputs binaries with broken paths sounds like something we should report as a bug upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was PBUK. Paths looked ok.... but not when I scrolled up. And it didn't build until I made that change.

It's a known issue apparently https://discourse.nixos.org/t/patchelf-for-mach-o-shared-libraries/562/6 there's even a hook for it fixDarwinDylibNames.

'';

postInstall = ''
${patchLibs}
mkdir -p $out/include
cp src/cbox.h $out/include
'';
Expand All @@ -32,14 +38,20 @@ self: super: {
sourceRoot = "libzauth/libzauth-c";

cargoSha256 = "10ijvi3rnnqpy589hhhp8s4p7xfpsbb1c3mzqnf65ra96q4nd6bf"; # self.lib.fakeSha256;

patchLibs = super.lib.optionalString super.stdenv.isDarwin ''
install_name_tool -id $out/lib/libzauth.dylib $out/lib/libzauth.dylib
'';

postInstall = ''
mkdir -p $out/lib/pkgconfig
mkdir -p $out/include
cp src/zauth.h $out/include
sed -e "s~<<VERSION>>~${version}~" \
-e "s~<<PREFIX>>~$out~" \
src/libzauth.pc > $out/lib/pkgconfig/libzauth.pc
cp target/release-tmp/libzauth.so $out/lib/
cp target/release-tmp/libzauth.* $out/lib/
${patchLibs}
'';
}
) {};
Expand Down
7 changes: 7 additions & 0 deletions stack-deps.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
with (import <nixpkgs> {});
let
pkgs = import ./nix;
native_libs = lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
Cocoa
CoreServices
]);

in
pkgs.haskell.lib.buildStackProject {
name = "wire-server";
nativeBuildInputs = native_libs;
buildInputs = with pkgs; [
cryptobox
geoip
Expand Down