@ -14,14 +14,16 @@
# Always assume all markers valid (don't redownload dependencies).
# Also, don't clean up environment variables.
, enableNixHacks ? false
, gcc-unwrapped
, autoPatchelfHook
} :
let
version = " 0 . 2 6 . 1 " ;
version = " 0 . 2 7 . 0 " ;
src = fetchurl {
url = " h t t p s : / / g i t h u b . c o m / b a z e l b u i l d / b a z e l / r e l e a s e s / d o w n l o a d / ${ version } / b a z e l - ${ version } - d i s t . z i p " ;
sha256 = " 0 0 0 n y 5 1 h w n j y i z m 1 m d 4 w 8 q 7 m 8 3 2 j h f 3 c 7 6 7 p g b v g 6 n c 7 h 6 7 l z s f 0 " ;
sha256 = " 0 y n 6 6 2 d z g f r 8 l s 4 a v f l 1 2 k 5 s r 4 f 2 1 0 b a b 1 2 w m l 1 8 b h 4 s j l x h s 2 6 3 " ;
} ;
# Update with `eval $(nix-build -A bazel.updater)`,
@ -40,12 +42,12 @@ let
srcs . bazel_skylib
srcs . io_bazel_rules_sass
( if stdenv . hostPlatform . isDarwin
then srcs . ${ " j a v a _ t o o l s _ j a v a c 1 0 _ d a r w i n - v 3 . 2 . z i p " }
else srcs . ${ " j a v a _ t o o l s _ j a v a c 1 0 _ l i n u x - v 3 . 2 . z i p " } )
then srcs . ${ " j a v a _ t o o l s _ j a v a c 1 1 _ d a r w i n - v 2 . 0 . z i p " }
else srcs . ${ " j a v a _ t o o l s _ j a v a c 1 1 _ l i n u x - v 2 . 0 . z i p " } )
srcs . ${ " c o v e r a g e _ o u t p u t _ g e n e r a t o r - v 1 . 0 . z i p " }
srcs . build_bazel_rules_nodejs
srcs . ${ " a n d r o i d _ t o o l s _ p k g - 0 . 2 . t a r . g z " }
] ;
srcs . ${ " a n d r o i d _ t o o l s _ p k g - 0 . 4 . t a r . g z " }
] ;
distDir = runCommand " b a z e l - d e p s " { } ''
mkdir - p $ out
@ -87,6 +89,36 @@ let
platforms = lib . platforms . linux ++ lib . platforms . darwin ;
# This repository is fetched by bazel at runtime
# however it contains prebuilt java binaries, with wrong interpreter
# and libraries path.
# We prefetch it, patch it, and override it in a global bazelrc.
system = if stdenv . hostPlatform . isDarwin
then " d a r w i n " else " l i n u x " ;
remote_java_tools = stdenv . mkDerivation {
name = " r e m o t e _ j a v a _ t o o l s _ ${ system } " ;
src = fetchurl {
url = " h t t p s : / / m i r r o r . b a z e l . b u i l d / b a z e l _ j a v a _ t o o l s / r e l e a s e s / j a v a c 1 1 / v 2 . 0 / j a v a _ t o o l s _ j a v a c 1 1 _ ${ system } - v 2 . 0 . z i p " ;
sha256 = " 0 7 4 d 6 2 4 f b 3 4 4 4 1 d f 3 6 9 a f d f d 4 5 4 e 7 5 d b a 8 2 1 d 5 d 5 4 9 3 2 f c f e e 5 b a 5 9 8 d 1 7 d c 1 b 9 9 " ;
} ;
nativeBuildInputs = [ autoPatchelfHook unzip ] ;
buildInputs = [ gcc-unwrapped ] ;
sourceRoot = " . " ;
buildPhase = ''
mkdir $ out ;
'' ;
installPhase = ''
cp - Ra * $ out /
touch $ out/WORKSPACE
'' ;
} ;
in
stdenv . mkDerivation rec {
name = " b a z e l - ${ version } " ;
@ -117,6 +149,7 @@ stdenv.mkDerivation rec {
runLocal = name : attrs : script : runCommandCC name ( {
preferLocalBuild = true ;
meta . platforms = platforms ;
buildInputs = [ python3 ] ;
} // attrs ) script ;
# bazel wants to extract itself into $install_dir/install every time it runs,
@ -275,6 +308,11 @@ stdenv.mkDerivation rec {
- - replace /bin/true $ { coreutils } /bin/true
done
# bazel test runner include references to /bin/bash
substituteInPlace tools/build_rules/test_rules.bzl \
- - replace /bin/bash $ { customBash } /bin/bash
# Fixup scripts that generate scripts. Not fixed up by patchShebangs below.
substituteInPlace scripts/bootstrap/compile.sh \
- - replace /bin/bash $ { customBash } /bin/bash
@ -323,12 +361,20 @@ stdenv.mkDerivation rec {
mv runfiles . bash . tmp tools/bash/runfiles/runfiles.bash
patchShebangs .
# bazel reads its system bazelrc in /etc
# override this path to a builtin one
substituteInPlace \
src/main/cpp/option_processor.cc \
- - replace BAZEL_SYSTEM_BAZELRC_PATH " \" $ o u t / e t c / b a z e l r c \" "
'' ;
in lib . optionalString stdenv . hostPlatform . isDarwin darwinPatches
+ genericPatches ;
buildInputs = [
buildJdk
python3 # bazel build requires python3. However we still use python2 for most of the other tasks
# This will have to be refactored later.
] ;
# when a command can’t be found in a bazel build, you might also
@ -375,6 +421,12 @@ stdenv.mkDerivation rec {
wrapProgram " $ o u t / b i n / b a z e l " - - add-flags - - server_javabase = " ${ runJdk } "
# generates the system bazelrc
# warning: the name of the repository depends on the system, hence
# the reference to .name
mkdir $ out/etc
echo " b u i l d - - o v e r r i d e _ r e p o s i t o r y = ${ remote_java_tools . name } = ${ remote_java_tools } " > $ out/etc/bazelrc
# shell completion files
mkdir - p $ out/share/bash-completion/completions $ out/share/zsh/site-functions
mv ./bazel_src/output/bazel-complete.bash $ out/share/bash-completion/completions/bazel