@@ -1,5 +1,7 @@
{ stdenv , callPackage , lib , fetchurl , fetchpatch , runCommand , makeWrapper
, zip , unzip , bash , writeCBin , coreutils
{ stdenv , callPackage , lib , fetchurl , fetchpatch , runCommand , runCommandCC , makeWrapper
# this package (through the fixpoint glass)
, bazel
, lr , xe , zip , unzip , bash , writeCBin , coreutils
, which , python , perl , gawk , gnused , gnutar , gnugrep , gzip , findutils
# Apple dependencies
, cctools , clang , libcxx , CoreFoundation , CoreServices , Foundation
@@ -14,14 +16,42 @@
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 / b a z e l _ j a v a _ t o o l s / j a v a _ t o o l s _ p k g - 0 . 5 . 1 . t a r . g z " ;
sha256 = " 1 l d 8 m 5 c j 9 j 0 r 4 7 4 f 5 6 p i x c f i 0 x v x 3 w 7 p z w a h x n g s 8 f 6 n s 0 y i m z 5 w " ;
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 " ;
} )
] ;
@@ -63,17 +93,19 @@ let
# 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 } " ;
platforms = lib . platforms . linux ++ lib . platforms . darwin ;
in
stdenv . mkDerivation rec {
version = " 0 . 2 4 . 0 " ;
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 ;
maintainers = [ maintainers . mboes ] ;
platforms = platforms . linux ++ platforms . darwin ;
inherit platforms ;
} ;
# Additional tests that check bazel’ s functionality. Execute
@@ -81,16 +113,68 @@ stdenv.mkDerivation rec {
# 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 { } ;
} ;
passthru . tests =
let
runLocal = name : attrs : script : runCommandCC name ( {
preferLocalBuild = true ;
meta . platforms = platforms ;
} // attrs ) script ;
# bazel wants to extract itself into $install_dir/install every time it runs,
# so let’ s do that only once.
extracted =
let install_dir =
# `install_base` field printed by `bazel info`, minus the hash.
# yes, this path is kinda magic. Sorry.
" $ H O M E / . c a c h e / b a z e l / _ b a z e l _ n i x b l d " ;
in runLocal " b a z e l - e x t r a c t e d - h o m e d i r " { passthru . install_dir = install_dir ; } ''
e x p o r t H O M E = $( m k t e m p - d )
t o u c h W O R K S P A C E # y e a h , e v e r y t h i n g s u c k s
i n s t a l l _ b a s e = " $( ${ bazel } / b i n / b a z e l i n f o | g r e p i n s t a l l _ b a s e ) "
# a s s e r t i t ’ s a c t u a l l y b e l o w i n s t a l l _ d i r
[ [ " $i n s t a l l _ b a s e " = ~ ${ install_dir } ] ] \
| | ( e c h o " o h n o ! $i n s t a l l _ b a s e b u t w e a r e \
t r y i n g t o c o p y ${ install_dir } t o $o u t i n s t e a d ! " ; e x i t 1 )
c p - R ${ install_dir } $o u t
'' ;
bazelTest = { name , bazelScript , workspaceDir }:
runLocal name { } (
# skip extraction caching on Darwin, because nobody knows how Darwin works
( lib . optionalString ( ! stdenv . hostPlatform . isDarwin ) ''
# s e t u p h o m e w i t h p r e - u n p a c k e d b a z e l
e x p o r t H O M E = $( m k t e m p - d )
m k d i r - p ${ extracted . install_dir }
c p - R ${ extracted } / i n s t a l l ${ extracted . install_dir }
# h t t p s : / / s t a c k o v e r f l o w . c o m / q u e s t i o n s / 4 7 7 7 5 6 6 8 / b a z e l - h o w - t o - s k i p - c o r r u p t - i n s t a l l a t i o n - o n - c e n t o s 6
# B a z e l c h e c k s w h e t h e r t h e m t i m e o f t h e i n s t a l l d i r f i l e s
# i s > 9 y e a r s i n t h e f u t u r e , o t h e r w i s e i t e x t r a c t s i t s e l f a g a i n .
# s e e P o s i x F i l e M T i m e : : I s U n t a m p e r e d i n s r c / m a i n / c p p / u t i l
# W h a t t h e h e l l b a z e l .
${ lr } / b i n / l r - 0 - U ${ extracted . install_dir } | ${ xe } / b i n / x e - N 0 - 0 t o u c h - - d a t e = " 9 y e a r s 6 m o n t h s " { }
'' )
+
''
# N o t e 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 / i s s u e s / 5 7 6 3 # i s s u e c o m m e n t - 4 5 6 3 7 4 6 0 9
# a b o u t w h y t o c r e a t e a s u b d i r f o r t h e w o r k s p a c e .
c p - r ${ workspaceDir } w d & & c h m o d u + w w d & & c d w d
${ bazelScript }
t o u c h $o u t
'' ) ;
in {
pythonBinPath = callPackage ./python-bin-path-test.nix { inherit runLocal bazelTest ; } ;
bashTools = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest ; } ;
} ;
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 = " 1 1 g s c 0 0 g h x q k b c i 8 n r f l k w q 1 l c v q a w l g k a r y j 4 5 8 b 2 4 s i 6 b j l 7 b 2 " ;
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.
@@ -148,10 +232,6 @@ stdenv.mkDerivation rec {
# 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 "
# 1 0 . 1 0 a p p l e _ s d k F o u n d a t i o n d o e s n ' t h a v e t y p e a r g u m e n t s o n c l a s s e s
# R e m o v e t h i s w h e n w e u p d a t e a p p l e _ s d k
s e d - i - e ' s / < . * \ * > / / g ' t o o l s / o s x / x c o d e _ l o c a t o r . m
# 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 \
@@ -159,6 +239,9 @@ stdenv.mkDerivation rec {
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
@@ -193,7 +276,7 @@ stdenv.mkDerivation rec {
# 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 / s h ${ customBash } / b i n / b a 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
@@ -297,7 +380,9 @@ stdenv.mkDerivation rec {
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 /
'' ;
doInstallCheck = true ;
# 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 )