about summary refs log tree commit diff
path: root/third_party/bazel/rules_haskell/nixpkgs/cc-toolchain.nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-07-04T10·18+0100
committerVincent Ambo <tazjin@google.com>2019-07-04T10·18+0100
commitf723b8b878a3c4a4687b9e337a875500bebb39b1 (patch)
treee85204cf042c355e90cff61c111e7d8cd15df311 /third_party/bazel/rules_haskell/nixpkgs/cc-toolchain.nix
parent2eb1dc26e42ffbdc168f05ef744bd4b4f3e4c36f (diff)
feat(third_party/bazel): Check in rules_haskell from Tweag r/17
Diffstat (limited to 'third_party/bazel/rules_haskell/nixpkgs/cc-toolchain.nix')
-rw-r--r--third_party/bazel/rules_haskell/nixpkgs/cc-toolchain.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/third_party/bazel/rules_haskell/nixpkgs/cc-toolchain.nix b/third_party/bazel/rules_haskell/nixpkgs/cc-toolchain.nix
new file mode 100644
index 000000000000..1795dc55b71b
--- /dev/null
+++ b/third_party/bazel/rules_haskell/nixpkgs/cc-toolchain.nix
@@ -0,0 +1,36 @@
+with import ./. {};
+with darwin.apple_sdk.frameworks;
+
+# XXX On Darwin, workaround
+# https://github.com/NixOS/nixpkgs/issues/42059. See also
+# https://github.com/NixOS/nixpkgs/pull/41589.
+let cc = runCommand "cc-wrapper-bazel" {
+    buildInputs = [ pkgs.stdenv.cc makeWrapper ];
+  }
+  ''
+    mkdir -p $out/bin
+
+    # Copy the content of pkgs.stdenv.cc
+    for i in ${pkgs.stdenv.cc}/bin/*
+    do
+      ln -sf $i $out/bin
+    done
+
+    # Override clang
+    rm $out/bin/clang
+
+    makeWrapper ${pkgs.stdenv.cc}/bin/clang $out/bin/clang \
+      --add-flags "-isystem ${llvmPackages.libcxx}/include/c++/v1 \
+                   -F${CoreFoundation}/Library/Frameworks \
+                   -F${CoreServices}/Library/Frameworks \
+                   -F${Security}/Library/Frameworks \
+                   -F${Foundation}/Library/Frameworks \
+                   -L${libcxx}/lib \
+                   -L${darwin.libobjc}/lib"
+  '';
+  stdenv = if pkgs.stdenv.isDarwin then overrideCC pkgs.stdenv cc else pkgs.stdenv;
+in
+buildEnv {
+  name = "bazel-cc-toolchain";
+  paths = [ stdenv.cc ] ++ (if stdenv.isDarwin then [ ] else [ binutils ]);
+}