@@ -0,0 +1,375 @@
{ stdenv , callPackage , lib , fetchurl , fetchpatch , runCommand , makeWrapper
, zip , unzip , bash , writeCBin , coreutils
, which , python , perl , gawk , gnused , gnutar , gnugrep , gzip , findutils
# Apple dependencies
, cctools , clang , libcxx , CoreFoundation , CoreServices , Foundation
# Allow to independently override the jdks used to build and run respectively
, buildJdk , runJdk
, buildJdkName
, runtimeShell
# Always assume all markers valid (don't redownload dependencies).
# Also, don't clean up environment variables.
, enableNixHacks ? false
}:
let
srcDeps = [
# From: $REPO_ROOT/WORKSPACE
( fetchurl {
url = " h t t p s : / / g i t h u b . c o m / g o o g l e / d e s u g a r _ j d k _ l i b s / a r c h i v e / 9 1 5 f 5 6 6 d 1 d c 2 3 b c 5 a 8 9 7 5 3 2 0 c d 2 f f 7 1 b e 1 0 8 e b 9 c . z i p " ;
sha256 = " 0 b 9 2 6 d f 7 y x y y y i w m 9 c m d i j y 6 k p l f 0 s g h m 2 3 s f 1 6 3 z h 8 w r k 8 7 w f i 7 " ;
} )
( fetchurl {
url = " h t t p s : / / m i r r o r . b a z e l . b u i l d / g i t h u b . c o m / b a z e l b u i l d / s k y d o c / a r c h i v e / 2 d 9 5 6 6 b 2 1 f b e 4 0 5 a c f 5 f 7 b f 7 7 e d a 3 0 d f 7 2 a 4 7 4 4 c . t a r . g z " ;
sha256 = " 4 a 1 3 1 8 f e d 4 8 3 1 6 9 7 b 8 3 c e 8 7 9 b 3 a b 7 0 a e 0 9 5 9 2 b 1 6 7 e 5 b d a 8 e d a f f 4 5 1 3 2 d 1 c 3 b 3 f " ;
} )
( fetchurl {
url = " h t t p s : / / m i r r o r . b a z e l . b u i l d / g i t h u b . c o m / b a z e l b u i l d / b a z e l - s k y l i b / a r c h i v e / f 8 3 c b 8 d d 6 f 5 6 5 8 b c 5 7 4 c c d 8 7 3 e 2 5 1 9 7 0 5 5 2 6 5 d 1 c . t a r . g z " ;
sha256 = " b a 5 d 1 5 c a 2 3 0 e f c a 9 6 3 2 0 0 8 5 d 8 e 4 d 5 8 d a 8 2 6 d 1 f 8 1 b 4 4 4 e f 8 a f c c d 8 b 2 3 e 0 7 9 9 b 5 2 " ;
} )
( fetchurl {
url = " h t t p s : / / m i r r o r . b a z e l . b u i l d / g i t h u b . c o m / b a z e l b u i l d / r u l e s _ s a s s / a r c h i v e / 8 c c f 4 f 1 c 3 5 1 9 2 8 b 5 5 d 5 d d d f 3 6 7 2 e 3 6 6 7 f 6 9 7 8 d 6 0 . t a r . g z " ;
sha256 = " d 8 6 8 c e 5 0 d 5 9 2 e f 4 a a d 7 d e c 4 d d 3 2 a e 6 8 d 2 1 5 1 2 6 1 9 1 3 4 5 0 f a c 8 3 9 0 b 3 f d 4 7 4 b b 8 9 8 " ;
} )
( 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 0 / v 3 . 1 / j a v a _ t o o l s _ j a v a c 1 0 _ l i n u x - v 3 . 1 . z i p " ;
sha256 = " a 0 c d 5 1 f 9 d b 1 b f 0 5 a 7 2 2 f f 7 f 5 c 6 0 a 0 7 f a 1 c 7 d 2 7 4 2 8 f f f 0 8 1 5 c 3 4 2 d 3 2 a a 6 c 5 3 5 7 6 " ;
} )
( 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 0 / v 3 . 1 / j a v a _ t o o l s _ j a v a c 1 0 _ d a r w i n - v 3 . 1 . z i p " ;
sha256 = " c 6 4 6 a a d 8 8 0 8 b 8 e c 5 8 4 4 d 6 a 8 0 a 1 2 8 7 f c 8 e 1 3 2 0 3 3 7 5 f e 4 0 d 6 a f 4 8 1 9 e f f 4 8 b 9 b b a f " ;
} )
( 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 _ c o v e r a g e _ o u t p u t _ g e n e r a t o r / r e l e a s e s / 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 " ;
sha256 = " c c 4 7 0 e 5 2 9 f a f b 6 1 6 5 b 5 b e 3 9 2 9 f f 2 d 9 9 b 3 8 4 2 9 b 3 8 6 a c 1 0 0 8 7 8 6 8 7 4 1 6 6 0 3 a 6 7 8 8 9 " ;
} )
( 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 / r u l e s _ n o d e j s / a r c h i v e / 0 . 1 6 . 2 . z i p " ;
sha256 = " 9 b 7 2 b b 0 a e a 7 2 d 7 c b c f c 8 2 a 0 1 b 1 e 2 5 b f 3 d 8 5 f 7 9 1 e 7 9 0 d d e c 1 6 c 6 5 e 2 d 9 0 6 3 8 2 e e 0 " ;
} )
( 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 _ a n d r o i d _ t o o l s / a n d r o i d _ t o o l s _ p k g - 0 . 2 . t a r . g z " ;
sha256 = " 0 4 f 8 5 f 2 d d 0 4 9 e 8 7 8 0 5 5 1 1 e 3 b a b c 5 c e a 3 f 5 e 7 2 3 3 2 b 1 6 2 7 e 3 4 f 3 a 5 4 6 1 c c 3 8 e 8 1 5 f " ;
} )
] ;
distDir = runCommand " b a z e l - d e p s " { } ''
m k d i r - p $o u t
f o r i i n ${ builtins . toString srcDeps } ; d o c p $i $o u t / $( s t r i p H a s h $i ) ; d o n e
'' ;
defaultShellPath = lib . makeBinPath
# Keep this list conservative. For more exotic tools, prefer to use
# @rules_nixpkgs to pull in tools from the nix repository. Example:
#
# WORKSPACE:
#
# nixpkgs_git_repository(
# name = "nixpkgs",
# revision = "def5124ec8367efdba95a99523dd06d918cb0ae8",
# )
#
# # This defines an external Bazel workspace.
# nixpkgs_package(
# name = "bison",
# repositories = { "nixpkgs": "@nixpkgs//:default.nix" },
# )
#
# some/BUILD.bazel:
#
# genrule(
# ...
# cmd = "$(location @bison//:bin/bison) -other -args",
# tools = [
# ...
# "@bison//:bin/bison",
# ],
# )
#
[ bash coreutils findutils gawk gnugrep gnutar gnused gzip which unzip ] ;
# Java toolchain used for the build and tests
javaToolchain = " @ b a z e l _ t o o l s / / t o o l s / j d k : t o o l c h a i n _ h o s t ${ buildJdkName } " ;
in
stdenv . mkDerivation rec {
version = " 0 . 2 6 . 0 " ;
meta = with lib ; {
homepage = " 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 / " ;
description = " B u i l d t o o l t h a t b u i l d s c o d e q u i c k l y a n d r e l i a b l y " ;
license = licenses . asl20 ;
platforms = platforms . linux ++ platforms . darwin ;
} ;
# Additional tests that check bazel’ s functionality. Execute
#
# nix-build . -A bazel.tests
#
# in the nixpkgs checkout root to exercise them locally.
passthru . tests = {
pythonBinPath = callPackage ./python-bin-path-test.nix { } ;
bashTools = callPackage ./bash-tools-test.nix { } ;
} ;
name = " b a z e l - ${ version } " ;
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 } / ${ name } - d i s t . z i p " ;
sha256 = " d 2 6 d a d f 6 2 9 5 9 2 5 5 d 5 8 e 5 2 3 d a 3 4 4 8 a 6 2 2 2 a f 7 6 8 f e 1 2 2 4 e 3 2 1 b 1 2 0 c 1 d 5 b b e 4 b 4 f 2 " ;
} ;
# Necessary for the tests to pass on Darwin with sandbox enabled.
# Bazel starts a local server and needs to bind a local address.
__darwinAllowLocalNetworking = true ;
sourceRoot = " . " ;
patches = [
./glibc.patch
./python-stub-path-fix.patch
] ++ lib . optional enableNixHacks ../nix-hacks.patch ;
# Bazel expects several utils to be available in Bash even without PATH. Hence this hack.
customBash = writeCBin " b a s h " ''
# i n c l u d e < s t d i o . h >
# i n c l u d e < s t d l i b . h >
# i n c l u d e < s t r i n g . h >
# i n c l u d e < u n i s t d . h >
e x t e r n c h a r * * e n v i r o n ;
i n t m a i n ( i n t a r g c , c h a r * a r g v [ ] ) {
c h a r * p a t h = g e t e n v ( " P A T H " ) ;
c h a r * p a t h T o A p p e n d = " ${ defaultShellPath } " ;
c h a r * n e w P a t h ;
i f ( p a t h ! = N U L L ) {
i n t l e n g t h = s t r l e n ( p a t h ) + 1 + s t r l e n ( p a t h T o A p p e n d ) + 1 ;
n e w P a t h = m a l l o c ( l e n g t h * s i z e o f ( c h a r ) ) ;
s n p r i n t f ( n e w P a t h , l e n g t h , " % s : % s " , p a t h , p a t h T o A p p e n d ) ;
} e l s e {
n e w P a t h = p a t h T o A p p e n d ;
}
s e t e n v ( " P A T H " , n e w P a t h , 1 ) ;
e x e c v e ( " ${ bash } / b i n / b a s h " , a r g v , e n v i r o n ) ;
r e t u r n 0 ;
}
'' ;
postPatch = let
darwinPatches = ''
# D i s a b l e B a z e l ' s X c o d e t o o l c h a i n d e t e c t i o n w h i c h w o u l d c o n f i g u r e c o m p i l e r s
# a n d l i n k e r s f r o m X c o d e i n s t e a d o f f r o m P A T H
e x p o r t B A Z E L _ U S E _ C P P _ O N L Y _ T O O L C H A I N = 1
# E x p l i c i t l y c o n f i g u r e g c o v s i n c e w e d o n ' t h a v e i t o n D a r w i n , s o a u t o d e t e c t i o n f a i l s
e x p o r t G C O V = ${ coreutils } / b i n / f a l s e
# F r a m e w o r k s e a r c h p a t h s a r e n ' t a d d e d b y b i n t o o l s h o o k
# h t t p s : / / g i t h u b . c o m / N i x O S / n i x p k g s / p u l l / 4 1 9 1 4
e x p o r t N I X _ L D F L A G S = " $N I X _ L D F L A G S - F ${ CoreFoundation } / L i b r a r y / F r a m e w o r k s - F ${ CoreServices } / L i b r a r y / F r a m e w o r k s - F ${ Foundation } / L i b r a r y / F r a m e w o r k s "
# l i b c x x i n c l u d e s a r e n ' t a d d e d b y l i b c x x h o o k
# h t t p s : / / g i t h u b . c o m / N i x O S / n i x p k g s / p u l l / 4 1 5 8 9
e x p o r t N I X _ C F L A G S _ C O M P I L E = " $N I X _ C F L A G S _ C O M P I L E - i s y s t e m ${ libcxx } / i n c l u d e / c + + / v 1 "
# d o n ' t u s e s y s t e m i n s t a l l e d X c o d e t o r u n c l a n g , u s e N i x c l a n g i n s t e a d
s e d - i - e " s ; / u s r / b i n / x c r u n c l a n g ; ${ stdenv . cc } / b i n / c l a n g $N I X _ C F L A G S _ C O M P I L E $N I X _ L D F L A G S - f r a m e w o r k C o r e F o u n d a t i o n ; g " \
s c r i p t s / b o o t s t r a p / c o m p i l e . s h \
s r c / t o o l s / x c o d e / r e a l p a t h / B U I L D \
s r c / t o o l s / x c o d e / s t d r e d i r e c t / B U I L D \
t o o l s / o s x / B U I L D
# n i x p k g s ' s l i b S y s t e m c a n n o t u s e p t h r e a d h e a d e r s d i r e c t l y , m u s t i m p o r t G C D h e a d e r s i n s t e a d
s e d - i - e " / # i n c l u d e < p t h r e a d \ / s p a w n . h > / i # i n c l u d e < d i s p a t c h / d i s p a t c h . h > " s r c / m a i n / c p p / b l a z e _ u t i l _ d a r w i n . c c
# c l a n g i n s t a l l e d f r o m X c o d e h a s a c o m p a t i b i l i t y w r a p p e r t h a t f o r w a r d s
# i n v o c a t i o n s o f g c c t o c l a n g , b u t v a n i l l a c l a n g d o e s n ' t
s e d - i - e ' s ; _ f i n d _ g e n e r i c ( r e p o s i t o r y _ c t x , " g c c " , " C C " , o v e r r i d e n _ t o o l s ) ; _ f i n d _ g e n e r i c ( r e p o s i t o r y _ c t x , " c l a n g " , " C C " , o v e r r i d e n _ t o o l s ) ; g ' t o o l s / c p p / u n i x _ c c _ c o n f i g u r e . b z l
s e d - i - e ' s ; / u s r / b i n / l i b t o o l ; ${ cctools } / b i n / l i b t o o l ; g ' t o o l s / c p p / u n i x _ c c _ c o n f i g u r e . b z l
w r a p p e r s = ( t o o l s / c p p / o s x _ c c _ w r a p p e r . s h t o o l s / c p p / o s x _ c c _ w r a p p e r . s h . t p l )
f o r w r a p p e r i n " ''$ { w r a p p e r s [ @ ] } " ; d o
s e d - i - e " s , / u s r / b i n / i n s t a l l _ n a m e _ t o o l , ${ cctools } / b i n / i n s t a l l _ n a m e _ t o o l , g " $w r a p p e r
d o n e
'' ;
genericPatches = ''
# S u b s t i t u t e p y t h o n ' s s t u b s h e b a n g t o p l a i n p y t h o n p a t h . ( s e e T O D O a d d p r U R L )
# S e e a l s o ` p o s t F i x u p ` w h e r e p y t h o n i s a d d e d t o $o u t / n i x - s u p p o r t
s u b s t i t u t e I n P l a c e s r c / m a i n / j a v a / c o m / g o o g l e / d e v t o o l s / b u i l d / l i b / b a z e l / r u l e s / p y t h o n / p y t h o n _ s t u b _ t e m p l a t e . t x t \
- - r e p l a c e " / u s r / b i n / e n v p y t h o n " " ${ python } / b i n / p y t h o n " \
- - r e p l a c e " N I X _ S T O R E _ P Y T H O N _ P A T H " " ${ python } / b i n / p y t h o n " \
# m d 5 s u m i s p a r t o f c o r e u t i l s
s e d - i ' s | / s b i n / m d 5 | m d 5 s u m | ' \
s r c / B U I L D
# s u b s t i t u t e I n P l a c e i s r a t h e r s l o w , s o p r e f i l t e r t h e f i l e s w i t h g r e p
g r e p - r l Z / b i n s r c / m a i n / j a v a / c o m / g o o g l e / d e v t o o l s | w h i l e I F S = " " r e a d - r - d " " p a t h ; d o
# I f y o u a d d m o r e r e p l a c e m e n t s h e r e , y o u m u s t c h a n g e t h e g r e p a b o v e !
# O n l y f i l e s c o n t a i n i n g / b i n a r e t a k e n i n t o a c c o u n t .
s u b s t i t u t e I n P l a c e " $p a t h " \
- - r e p l a c e / b i n / b a s h ${ customBash } / b i n / b a s h \
- - r e p l a c e / u s r / b i n / e n v ${ coreutils } / b i n / e n v \
- - r e p l a c e / b i n / t r u e ${ coreutils } / b i n / t r u e
d o n e
# F i x u p s c r i p t s t h a t g e n e r a t e s c r i p t s . N o t f i x e d u p b y p a t c h S h e b a n g s b e l o w .
s u b s t i t u t e I n P l a c e s c r i p t s / b o o t s t r a p / c o m p i l e . s h \
- - r e p l a c e / b i n / b a s h ${ customBash } / b i n / b a s h
# a d d n i x e n v i r o n m e n t v a r s t o . b a z e l r c
c a t > > . b a z e l r c < < E O F
b u i l d - - e x p e r i m e n t a l _ d i s t d i r = ${ distDir }
f e t c h - - e x p e r i m e n t a l _ d i s t d i r = ${ distDir }
b u i l d - - c o p t = " $( e c h o $N I X _ C F L A G S _ C O M P I L E | s e d - e ' s / / " - - c o p t = " / g ' ) "
b u i l d - - h o s t _ c o p t = " $( e c h o $N I X _ C F L A G S _ C O M P I L E | s e d - e ' s / / " - - h o s t _ c o p t = " / g ' ) "
b u i l d - - l i n k o p t = " - W l , $( e c h o $N I X _ L D F L A G S | s e d - e ' s / / " - - l i n k o p t = " - W l , / g ' ) "
b u i l d - - h o s t _ l i n k o p t = " - W l , $( e c h o $N I X _ L D F L A G S | s e d - e ' s / / " - - h o s t _ l i n k o p t = " - W l , / g ' ) "
b u i l d - - h o s t _ j a v a b a s e = ' @ l o c a l _ j d k / / : j d k '
b u i l d - - h o s t _ j a v a _ t o o l c h a i n = ' ${ javaToolchain } '
E O F
# a d d t h e s a m e e n v i r o n m e n t v a r s t o c o m p i l e . s h
s e d - e " / \ $c o m m a n d \ \ \ \ $/ a - - c o p t = \ " $( e c h o $N I X _ C F L A G S _ C O M P I L E | s e d - e ' s / / " - - c o p t = \ " / g ' ) \ " \ \ \ \ " \
- e " / \ $c o m m a n d \ \ \ \ $/ a - - h o s t _ c o p t = \ " $( e c h o $N I X _ C F L A G S _ C O M P I L E | s e d - e ' s / / " - - h o s t _ c o p t = \ " / g ' ) \ " \ \ \ \ " \
- e " / \ $c o m m a n d \ \ \ \ $/ a - - l i n k o p t = \ " - W l , $( e c h o $N I X _ L D F L A G S | s e d - e ' s / / " - - l i n k o p t = \ " - W l , / g ' ) \ " \ \ \ \ " \
- e " / \ $c o m m a n d \ \ \ \ $/ a - - h o s t _ l i n k o p t = \ " - W l , $( e c h o $N I X _ L D F L A G S | s e d - e ' s / / " - - h o s t _ l i n k o p t = \ " - W l , / g ' ) \ " \ \ \ \ " \
- e " / \ $c o m m a n d \ \ \ \ $/ a - - h o s t _ j a v a b a s e = ' @ l o c a l _ j d k / / : j d k ' \ \ \ \ " \
- e " / \ $c o m m a n d \ \ \ \ $/ a - - h o s t _ j a v a _ t o o l c h a i n = ' ${ javaToolchain } ' \ \ \ \ " \
- i s c r i p t s / b o o t s t r a p / c o m p i l e . s h
# - - e x p e r i m e n t a l _ s t r i c t _ a c t i o n _ e n v ( w h i c h w i l l s o o n b e c o m e t h e
# d e f a u l t , s e e b a z e l b u i l d / b a z e l # 2 5 7 4 ) h a r d c o d e s t h e d e f a u l t
# a c t i o n e n v i r o n m e n t t o a v a l u e t h a t o n N i x O S a t l e a s t i s b o g u s .
# S o w e h a r d c o d e i t t o s o m e t h i n g u s e f u l .
s u b s t i t u t e I n P l a c e \
s r c / m a i n / j a v a / c o m / g o o g l e / d e v t o o l s / b u i l d / l i b / b a z e l / r u l e s / B a z e l R u l e C l a s s P r o v i d e r . j a v a \
- - r e p l a c e / b i n : / u s r / b i n ${ defaultShellPath }
# T h i s i s n e c e s s a r y t o a v o i d :
# " e r r o r : n o v i s i b l e @ i n t e r f a c e f o r ' N S D i c t i o n a r y ' d e c l a r e s t h e s e l e c t o r
# ' i n i t W i t h C o n t e n t s O f U R L : e r r o r : ' "
# T h i s c a n b e r e m o v e d w h e n t h e a p p l e _ s d k i s u p g r a d e d b e y o n d 1 0 . 1 3 +
s e d - i ' / i n i t W i t h C o n t e n t s O f U R L : v e r s i o n P l i s t U r l / {
N
s / e r r o r : n i l \ ] ; / \ ] ; /
} ' t o o l s / o s x / x c o d e _ l o c a t o r . m
# a p p e n d t h e P A T H w i t h d e f a u l t S h e l l P a t h i n t o o l s / b a s h / r u n f i l e s / r u n f i l e s . b a s h
e c h o " P A T H = \ $P A T H : ${ defaultShellPath } " > > r u n f i l e s . b a s h . t m p
c a t t o o l s / b a s h / r u n f i l e s / r u n f i l e s . b a s h > > r u n f i l e s . b a s h . t m p
m v r u n f i l e s . b a s h . t m p t o o l s / b a s h / r u n f i l e s / r u n f i l e s . b a s h
p a t c h S h e b a n g s .
'' ;
in lib . optionalString stdenv . hostPlatform . isDarwin darwinPatches
+ genericPatches ;
buildInputs = [
buildJdk
] ;
# when a command can’ t be found in a bazel build, you might also
# need to add it to `defaultShellPath`.
nativeBuildInputs = [
zip
python
unzip
makeWrapper
which
customBash
] ++ lib . optionals ( stdenv . isDarwin ) [ cctools libcxx CoreFoundation CoreServices Foundation ] ;
# Bazel makes extensive use of symlinks in the WORKSPACE.
# This causes problems with infinite symlinks if the build output is in the same location as the
# Bazel WORKSPACE. This is why before executing the build, the source code is moved into a
# subdirectory.
# Failing to do this causes "infinite symlink expansion detected"
preBuildPhases = [ " p r e B u i l d P h a s e " ] ;
preBuildPhase = ''
m k d i r b a z e l _ s r c
s h o p t - s d o t g l o b e x t g l o b
m v ! ( b a z e l _ s r c ) b a z e l _ s r c
'' ;
buildPhase = ''
# I n c r e a s i n g m e m o r y d u r i n g c o m p i l a t i o n m i g h t b e n e c e s s a r y .
# e x p o r t B A Z E L _ J A V A C _ O P T S = " - J - X m x 2 g - J - X m s 2 0 0 m "
. / b a z e l _ s r c / c o m p i l e . s h
. / b a z e l _ s r c / s c r i p t s / g e n e r a t e _ b a s h _ c o m p l e t i o n . s h \
- - b a z e l = . / b a z e l _ s r c / o u t p u t / b a z e l \
- - o u t p u t = . / b a z e l _ s r c / o u t p u t / b a z e l - c o m p l e t e . b a s h \
- - p r e p e n d = . / b a z e l _ s r c / s c r i p t s / b a z e l - c o m p l e t e - h e a d e r . b a s h \
- - p r e p e n d = . / b a z e l _ s r c / s c r i p t s / b a z e l - c o m p l e t e - t e m p l a t e . b a s h
'' ;
installPhase = ''
m k d i r - p $o u t / b i n
# o f f i c i a l w r a p p e r s c r i p t s t h a t s e a r c h e s f o r $W O R K S P A C E _ R O O T / t o o l s / b a z e l
# i f i t c a n ’ t f i n d s o m e t h i n g i n t o o l s , i t c a l l s $o u t / b i n / b a z e l - r e a l
c p . / b a z e l _ s r c / s c r i p t s / p a c k a g e s / b a z e l . s h $o u t / b i n / b a z e l
m v . / b a z e l _ s r c / o u t p u t / b a z e l $o u t / b i n / b a z e l - r e a l
w r a p P r o g r a m " $o u t / b i n / b a z e l " - - a d d - f l a g s - - s e r v e r _ j a v a b a s e = " ${ runJdk } "
# s h e l l c o m p l e t i o n f i l e s
m k d i r - p $o u t / s h a r e / b a s h - c o m p l e t i o n / c o m p l e t i o n s $o u t / s h a r e / z s h / s i t e - f u n c t i o n s
m v . / b a z e l _ s r c / o u t p u t / b a z e l - c o m p l e t e . b a s h $o u t / s h a r e / b a s h - c o m p l e t i o n / c o m p l e t i o n s / b a z e l
c p . / b a z e l _ s r c / s c r i p t s / z s h _ c o m p l e t i o n / _ b a z e l $o u t / s h a r e / z s h / s i t e - f u n c t i o n s /
'' ;
# Temporarily disabling for now. A new approach is needed for this derivation as Bazel
# accesses the internet during the tests which fails in a sandbox.
doInstallCheck = false ;
installCheckPhase = ''
e x p o r t T E S T _ T M P D I R = $( p w d )
h e l l o _ t e s t ( ) {
$o u t / b i n / b a z e l t e s t \
- - t e s t _ o u t p u t = e r r o r s \
- - j a v a _ t o o l c h a i n = ' ${ javaToolchain } ' \
e x a m p l e s / c p p : h e l l o - s u c c e s s _ t e s t \
e x a m p l e s / j a v a - n a t i v e / s r c / t e s t / j a v a / c o m / e x a m p l e / m y p r o j e c t : h e l l o
}
c d . / b a z e l _ s r c
# t e s t w h e t h e r $W O R K S P A C E _ R O O T / t o o l s / b a z e l w o r k s
m k d i r - p t o o l s
c a t > t o o l s / b a z e l < < " E O F "
# ! ${ runtimeShell } - e
e x i t 1
E O F
c h m o d + x t o o l s / b a z e l
# f i r s t c a l l s h o u l d f a i l i f t o o l s / b a z e l i s u s e d
! h e l l o _ t e s t
c a t > t o o l s / b a z e l < < " E O F "
# ! ${ runtimeShell } - e
e x e c " $B A Z E L _ R E A L " " $@ "
E O F
# s e c o n d c a l l s u c c e e d s b e c a u s e i t d e f e r s t o $o u t / b i n / b a z e l - r e a l
h e l l o _ t e s t
'' ;
# Save paths to hardcoded dependencies so Nix can detect them.
postFixup = ''
m k d i r - p $o u t / n i x - s u p p o r t
e c h o " ${ customBash } ${ defaultShellPath } " > > $o u t / n i x - s u p p o r t / d e p e n d s
# T h e t e m p l a t e s g e t t a r ’ d u p i n t o a . j a r ,
# s o n i x c a n ’ t d e t e c t p y t h o n i s n e e d e d i n t h e r u n t i m e c l o s u r e
e c h o " ${ python } " > > $o u t / n i x - s u p p o r t / d e p e n d s
'' ;
dontStrip = true ;
dontPatchELF = true ;
}