From 424ac8b577b6fda42ca9005194288d66b82e13e0 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sun, 10 Sep 2023 13:03:32 +0200 Subject: fix(tvix): Get tvix build and shell to work on Darwin On Darwin rust crates sometimes needs iconv manually added to compile successfully. There is currently also a bug in strip that requires that you set dontStrip on buildRustCrate for it to work. See: https://github.com/NixOS/nixpkgs/issues/218712 Change-Id: I13555c7bbee1d34f08fc51a668d2067dbbe550ce Reviewed-on: https://cl.tvl.fyi/c/depot/+/9291 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/default.nix | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'tvix/default.nix') diff --git a/tvix/default.nix b/tvix/default.nix index 4abf27f463..f5f1ca47cb 100644 --- a/tvix/default.nix +++ b/tvix/default.nix @@ -4,13 +4,30 @@ let # crate override for crates that need protobuf protobufDep = prev: (prev.nativeBuildInputs or [ ]) ++ [ pkgs.protobuf ]; + iconvDarwinDep = lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ]; # Load the crate2nix crate tree. crates = import ./Cargo.nix { inherit pkgs; nixpkgs = pkgs.path; + # Hack to fix Darwin build + # See https://github.com/NixOS/nixpkgs/issues/218712 + buildRustCrateForPkgs = pkgs: + if pkgs.stdenv.isDarwin then + let + buildRustCrate = pkgs.buildRustCrate; + buildRustCrate_ = args: buildRustCrate args // { dontStrip = true; }; + override = o: args: buildRustCrate.override o (args // { dontStrip = true; }); + in + pkgs.makeOverridable override { } + else pkgs.buildRustCrate; + defaultCrateOverrides = pkgs.defaultCrateOverrides // { + zstd-sys = prev: { + nativeBuildInputs = prev.nativeBuildInputs or [ ] ++ iconvDarwinDep; + }; + fuser = prev: { buildInputs = prev.buildInputs or [ ] ++ [ pkgs.fuse ]; nativeBuildInputs = prev.nativeBuildInputs or [ ] ++ [ pkgs.pkg-config ]; @@ -86,7 +103,7 @@ in pkgs.rustc pkgs.rustfmt pkgs.protobuf - ]; + ] ++ iconvDarwinDep; }; # Builds and tests the code in store/protos. @@ -113,7 +130,7 @@ in protobuf rustc rustPlatform.cargoSetupHook - ]; + ] ++ iconvDarwinDep; buildPhase = '' cargo doc --document-private-items -- cgit 1.4.1