about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorBrian Olsen <brian@maven-group.org>2023-09-10T11·03+0200
committerBrian Olsen <me@griff.name>2023-09-11T10·11+0000
commit424ac8b577b6fda42ca9005194288d66b82e13e0 (patch)
tree8b32d62e934a52f644651f1e4f378a9a9e7f3a73 /tvix
parentb8df88843fd8527b98ef95a950cf03a21084a49a (diff)
fix(tvix): Get tvix build and shell to work on Darwin r/6579
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 <tazjin@tvl.su>
Diffstat (limited to 'tvix')
-rw-r--r--tvix/default.nix21
1 files changed, 19 insertions, 2 deletions
diff --git a/tvix/default.nix b/tvix/default.nix
index 4abf27f46374..f5f1ca47cbc9 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