diff options
author | Uri Baghin <uri@canva.com> | 2018-05-23 17:18:44 +1000 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2018-06-12 23:23:51 -0400 |
commit | 274bb96073d9b263821dc68a1d2d65bec24b99f2 (patch) | |
tree | 88fe22d0d7d6626b7735a4a4e606215b951ad267 /pkgs/development/tools | |
parent | 0acad472a4bf33ecadbdf3083f7b4745b218d44a (diff) | |
download | nixpkgs-274bb96073d9b263821dc68a1d2d65bec24b99f2.tar nixpkgs-274bb96073d9b263821dc68a1d2d65bec24b99f2.tar.gz nixpkgs-274bb96073d9b263821dc68a1d2d65bec24b99f2.tar.bz2 nixpkgs-274bb96073d9b263821dc68a1d2d65bec24b99f2.tar.lz nixpkgs-274bb96073d9b263821dc68a1d2d65bec24b99f2.tar.xz nixpkgs-274bb96073d9b263821dc68a1d2d65bec24b99f2.tar.zst nixpkgs-274bb96073d9b263821dc68a1d2d65bec24b99f2.zip |
bazel: add darwin support
Diffstat (limited to 'pkgs/development/tools')
-rw-r--r-- | pkgs/development/tools/build-managers/bazel/default.nix | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/pkgs/development/tools/build-managers/bazel/default.nix b/pkgs/development/tools/build-managers/bazel/default.nix index d5eaa24c167..e641e69bae6 100644 --- a/pkgs/development/tools/build-managers/bazel/default.nix +++ b/pkgs/development/tools/build-managers/bazel/default.nix @@ -1,7 +1,9 @@ -{ stdenv, lib, fetchurl, jdk, zip, unzip, bash, writeScriptBin, coreutils, makeWrapper, which, python +{ stdenv, lib, fetchurl, jdk, zip, unzip, bash, writeCBin, coreutils, makeWrapper, which, python # Always assume all markers valid (don't redownload dependencies). # Also, don't clean up environment variables. , enableNixHacks ? false +# Apple dependencies +, libcxx, CoreFoundation, CoreServices, Foundation }: stdenv.mkDerivation rec { @@ -13,7 +15,7 @@ stdenv.mkDerivation rec { description = "Build tool that builds code quickly and reliably"; license = licenses.asl20; maintainers = [ maintainers.philandstuff ]; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; }; name = "bazel-${version}"; @@ -29,9 +31,30 @@ stdenv.mkDerivation rec { # Bazel expects several utils to be available in Bash even without PATH. Hence this hack. - customBash = writeScriptBin "bash" '' - #!${stdenv.shell} - PATH="$PATH:${lib.makeBinPath [ coreutils ]}" exec ${bash}/bin/bash "$@" + customBash = writeCBin "bash" '' + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + #include <unistd.h> + + extern char **environ; + + int main(int argc, char *argv[]) { + printf("environ: %s\n", environ[0]); + char *path = getenv("PATH"); + char *pathToAppend = "${lib.makeBinPath [ coreutils ]}"; + char *newPath; + if (path != NULL) { + int length = strlen(path) + 1 + strlen(pathToAppend) + 1; + newPath = malloc(length * sizeof(char)); + snprintf(newPath, length, "%s:%s", path, pathToAppend); + } else { + newPath = pathToAppend; + } + setenv("PATH", newPath, 1); + execve("${bash}/bin/bash", argv, environ); + return 0; + } ''; postPatch = '' @@ -54,7 +77,7 @@ stdenv.mkDerivation rec { makeWrapper which customBash - ]; + ] ++ lib.optionals (stdenv.isDarwin) [ libcxx CoreFoundation CoreServices Foundation ]; # If TMPDIR is in the unpack dir we run afoul of blaze's infinite symlink # detector (see com.google.devtools.build.lib.skyframe.FileFunction). |