@@ -1,9 +1,15 @@
let lib = import ../../../lib ; in lib . makeOverridable (
{ system , name ? " s t d e n v " , preHook ? " " , initialPath , gcc , shell
, extraAttrs ? { } , overrides ? ( pkgs : { } ) , config
, # The `fetchurl' to use for downloading curl and its dependencies
# (see all-packages.nix).
fetchurlBoot
, setupScript ? ./setup.sh
, extraBuildInputs ? [ ]
}:
if ! builtins ? langVersion then
@@ -14,169 +20,155 @@ else
let
lib = import ../../../lib ;
allowUnfree = config . allowUnfree or true && builtins . getEnv " H Y D R A _ D I S A L L O W _ U N F R E E " != " 1 " ;
allowBroken = builtins . getEnv " N I X P K G S _ A L L O W _ B R O K E N " = = " 1 " ;
unsafeGetAttrPos = builtins . unsafeGetAttrPos or ( n : as : null ) ;
stdenvGenerator = setupScript : rec {
# The stdenv that we are producing.
result =
# The stdenv that we are producing.
result =
derivation {
inherit system name ;
derivation {
inherit system name ;
builder = shell ;
builder = shell ;
args = [ " - e " ./builder.sh ] ;
args = [ " - e " ./builder.sh ] ;
setup = setupScript ;
setup = setupScript ;
inherit preHook initialPath gcc shell ;
inherit preHook initialPath gcc shell ;
propagatedUserEnvPkgs = [ gcc ] ++
lib . filter lib . isDerivation initialPath ;
propagatedUserEnvPkgs = [ gcc ] ++
lib . filter lib . isDerivation initialPath ;
__ignoreNulls = true ;
}
__ignoreNulls = true ;
}
// rec {
// rec {
meta = {
description = " T h e d e f a u l t b u i l d e n v i r o n m e n t f o r U n i x p a c k a g e s i n N i x p k g s " ;
} ;
meta = {
description = " T h e d e f a u l t b u i l d e n v i r o n m e n t f o r U n i x p a c k a g e s i n N i x p k g s " ;
} ;
# Add a utility function to produce derivations that use this
# stdenv and its shell.
mkDerivation = attrs :
let
pos =
if attrs . meta . description or null != null then
unsafeGetAttrPos " d e s c r i p t i o n " attrs . meta
else
unsafeGetAttrPos " n a m e " attrs ;
pos' = if pos != null then " ‘ " + pos . file + " : " + toString pos . line + " ’ " else " « u n k n o w n - f i l e » " ;
in
if ! allowUnfree && ( let l = lib . lists . toList attrs . meta . license or [ ] ; in lib . lists . elem " u n f r e e " l || lib . lists . elem " u n f r e e - r e d i s t r i b u t a b l e " l ) then
throw " p a c k a g e ‘ ${ attrs . name } ’ i n ${ pos' } h a s a n u n f r e e l i c e n s e , r e f u s i n g t o e v a l u a t e "
else if ! allowBroken && attrs . meta . broken or false then
throw " y o u c a n ' t u s e p a c k a g e ‘ ${ attrs . name } ’ i n ${ pos' } b e c a u s e i t h a s b e e n m a r k e d a s b r o k e n "
else if ! allowBroken && attrs . meta . platforms or null != null && ! lib . lists . elem result . system attrs . meta . platforms then
throw " t h e p a c k a g e ‘ ${ attrs . name } ’ i n ${ pos' } i s n o t s u p p o r t e d o n ‘ ${ result . system } ’ "
else
lib . addPassthru ( derivation (
( removeAttrs attrs [ " m e t a " " p a s s t h r u " " c r o s s A t t r s " ] )
// ( let
buildInputs = attrs . buildInputs or [ ] ;
nativeBuildInputs = attrs . nativeBuildInputs or [ ] ;
propagatedBuildInputs = attrs . propagatedBuildInputs or [ ] ;
propagatedNativeBuildInputs = attrs . propagatedNativeBuildInputs or [ ] ;
crossConfig = attrs . crossConfig or null ;
in
{
builder = attrs . realBuilder or shell ;
args = attrs . args or [ " - e " ( attrs . builder or ./default-builder.sh ) ] ;
stdenv = result ;
system = result . system ;
userHook = config . stdenv . userHook or null ;
# Inputs built by the cross compiler.
buildInputs = lib . optionals ( crossConfig != null ) buildInputs ;
propagatedBuildInputs = lib . optionals ( crossConfig != null )
propagatedBuildInputs ;
# Inputs built by the usual native compiler.
nativeBuildInputs = nativeBuildInputs ++ lib . optionals
( crossConfig = = null ) buildInputs ;
propagatedNativeBuildInputs = propagatedNativeBuildInputs ++
lib . optionals ( crossConfig = = null ) propagatedBuildInputs ;
} ) ) ) (
# Add a utility function to produce derivations that use this
# stdenv and its shell.
mkDerivation = attrs :
let
pos =
if attrs . meta . description or null != null then
unsafeGetAttrPos " d e s c r i p t i o n " attrs . meta
else
unsafeGetAttrPos " n a m e " attrs ;
pos' = if pos != null then " ‘ " + pos . file + " : " + toString pos . line + " ’ " else " « u n k n o w n - f i l e » " ;
in
if ! allowUnfree && ( let l = lib . lists . toList attrs . meta . license or [ ] ; in lib . lists . elem " u n f r e e " l || lib . lists . elem " u n f r e e - r e d i s t r i b u t a b l e " l ) then
throw " p a c k a g e ‘ ${ attrs . name } ’ i n ${ pos' } h a s a n u n f r e e l i c e n s e , r e f u s i n g t o e v a l u a t e "
else if ! allowBroken && attrs . meta . broken or false then
throw " y o u c a n ' t u s e p a c k a g e ‘ ${ attrs . name } ’ i n ${ pos' } b e c a u s e i t h a s b e e n m a r k e d a s b r o k e n "
else if ! allowBroken && attrs . meta . platforms or null != null && ! lib . lists . elem result . system attrs . meta . platforms then
throw "t h e p a c k a g e ‘ ${ attrs . name } ’ i n ${ pos' } i s n o t s u p p o r t e d o n ‘ ${ result . system } ’ "
else
lib . addPassthru ( derivation (
( removeAttrs attrs [ " m e t a " " p a s s t h r u " " c r o s s A t t r s " ] )
// ( let
buildInputs = attrs . buildInputs or [ ] ;
nativeBuildInputs = attrs . nativeBuildInputs or [ ] ;
propagatedBuildInputs = attrs . propagatedBuildInputs or [ ] ;
propagatedNativeBuildInputs = attrs . propagatedNativeBuildInputs or [ ] ;
crossConfig = attrs . crossConfig or null ;
in
{
# The meta attribute is passed in the resulting attribute set,
# but it's not part of the actual derivation, i.e., it's not
# passed to the builder and is not a dependency. But since we
# include it in the result, it *is* available to nix-env for
# queries. We also a meta.position attribute here to
# identify the source location of the package.
meta = attrs . meta or { } // ( if pos != null then {
position = pos . file + " : " + ( toString pos . line ) ;
} else { } ) ;
passthru = attrs . passthru or { } ;
} //
# Pass through extra attributes that are not inputs, but
# should be made available to Nix expressions using the
# derivation (e.g., in assertions).
( attrs . passthru or { } ) ) ;
builder = attrs . realBuilder or shell ;
args = attrs . args or [ " - e " ( attrs . builder or ./default-builder.sh ) ] ;
stdenv = result ;
system = result . system ;
userHook = config . stdenv . userHook or null ;
# Utility flags to test the type of platform .
isDarwin = result . system = = " x 8 6 _ 6 4 - d a r w i n " ;
isLinux = result . system = = " i 6 8 6 - l i n u x "
|| result . system = = " x 8 6 _ 6 4 - l i n u x "
|| result . system = = " p o w e r p c - l i n u x "
|| result . system = = " a r m v 5 t e l - l i n u x "
|| result . system = = " a r m v 6 l - l i n u x "
|| result . system = = " a r m v 7 l - l i n u x "
|| result . system = = " m i p s 6 4 e l - l i n u x " ;
isGNU = result . system = = " i 6 8 6 - g n u " ; # GNU/Hurd
isGlibc = isGNU # useful for `stdenvNative'
|| isLinux
|| result . system = = " x 8 6 _ 6 4 - k f r e e b s d - g n u " ;
isSunOS = result . system = = " i 6 8 6 - s o l a r i s "
|| result . system = = " x 8 6 _ 6 4 - s o l a r i s " ;
isCygwin = result . system = = " i 6 8 6 - c y g w i n " ;
isFreeBSD = result . system = = " i 6 8 6 - f r e e b s d "
|| result . system = = " x 8 6 _ 6 4 - f r e e b s d " ;
isOpenBSD = result . system = = " i 6 8 6 - o p e n b s d "
|| result . system = = " x 8 6 _ 6 4 - o p e n b s d " ;
isBSD = result . system = = " i 6 8 6 - f r e e b s d "
|| result . system = = " x 8 6 _ 6 4 - f r e e b s d "
|| result . system = = " i 6 8 6 - o p e n b s d "
|| result . system = = " x 8 6 _ 6 4 - o p e n b s d " ;
isi686 = result . system = = " i 6 8 6 - l i n u x "
|| result . system = = " i 6 8 6 - g n u "
|| result . system = = " i 6 8 6 - f r e e b s d "
|| result . system = = " i 6 8 6 - o p e n b s d "
|| result . system = = " i 3 8 6 - s u n o s " ;
isx86_64 = result . system = = " x 8 6 _ 6 4 - l i n u x "
|| result . system = = " x 8 6 _ 6 4 - d a r w i n "
|| result . system = = " x 8 6 _ 6 4 - f r e e b s d "
|| result . system = = " x 8 6 _ 6 4 - o p e n b s d "
|| result . system = = " x 8 6 _ 6 4 - s o l a r i s " ;
is64bit = result . system = = " x 8 6 _ 6 4 - l i n u x "
|| result . system = = " x 8 6 _ 6 4 - d a r w i n "
|| result . system = = " x 8 6 _ 6 4 - f r e e b s d "
|| result . system = = " x 8 6 _ 6 4 - o p e n b s d "
|| result . system = = " x 8 6 _ 6 4 - s o l a r i s " ;
isMips = result . system = = " m i p s - l i n u x "
|| result . system = = " m i p s 6 4 e l - l i n u x " ;
isArm = result . system = = " a r m v 5 t e l - l i n u x "
# Inputs built by the cross compiler .
buildInputs = lib . optionals ( crossConfig != null ) buildInputs ++ extraBuildInputs ;
propagatedBuildInputs = lib . optionals ( crossConfig != null ) propagatedBuildInputs ;
# Inputs built by the usual native compiler.
nativeBuildInputs = nativeBuildInputs ++ lib . optionals ( crossConfig = = null ) buildInputs ;
propagatedNativeBuildInputs = propagatedNativeBuildInputs ++
lib . optionals ( crossConfig = = null ) propagatedBuildInputs ;
} ) ) ) (
{
# The meta attribute is passed in the resulting attribute set,
# but it's not part of the actual derivation, i.e., it's not
# passed to the builder and is not a dependency. But since we
# include it in the result, it *is* available to nix-env for
# queries. We also a meta.position attribute here to
# identify the source location of the package.
meta = attrs . meta or { } // ( if pos != null then {
position = pos . file + " : " + ( toString pos . line ) ;
} else { } ) ;
passthru = attrs . passthru or { } ;
} //
# Pass through extra attributes that are not inputs, but
# should be made available to Nix expressions using the
# derivation (e.g., in assertions).
( attrs . passthru or { } ) ) ;
# Utility flags to test the type of platform.
isDarwin = result . system = = " x 8 6 _ 6 4 - d a r w i n " ;
isLinux = result . system = = " i 6 8 6 - l i n u x "
|| result . system = = " x 8 6 _ 6 4 -l i n u x "
|| result . system = = " p o w e r p c - l i n u x "
|| result . system = = " a r m v 5 t e l - l i n u x "
|| result . system = = " a r m v 6 l - l i n u x "
|| result . system = = " a r m v 7 l - l i n u x " ;
|| result . system = = " a r m v 7 l - l i n u x "
|| result . system = = " m i p s 6 4 e l - l i n u x " ;
isGNU = result . system = = " i 6 8 6 - g n u " ; # GNU/Hurd
isGlibc = isGNU # useful for `stdenvNative'
|| isLinux
|| result . system = = " x 8 6 _ 6 4 - k f r e e b s d - g n u " ;
isSunOS = result . system = = " i 6 8 6 - s o l a r i s "
|| result . system = = " x 8 6 _ 6 4 - s o l a r i s " ;
isCygwin = result . system = = " i 6 8 6 - c y g w i n " ;
isFreeBSD = result . system = = " i 6 8 6 - f r e e b s d "
|| result . system = = " x 8 6 _ 6 4 - f r e e b s d " ;
isOpenBSD = result . system = = " i 6 8 6 - o p e n b s d "
|| result . system = = " x 8 6 _ 6 4 - o p e n b s d " ;
isBSD = result . system = = " i 6 8 6 - f r e e b s d "
|| result . system = = " x 8 6 _ 6 4 - f r e e b s d "
|| result . system = = " i 6 8 6 - o p e n b s d "
|| result . system = = " x 8 6 _ 6 4 - o p e n b s d " ;
isi686 = result . system = = " i 6 8 6 - l i n u x "
|| result . system = = " i 6 8 6 - g n u "
|| result . system = = " i 6 8 6 - f r e e b s d "
|| result . system = = " i 6 8 6 - o p e n b s d "
|| result . system = = " i 3 8 6 - s u n o s " ;
isx86_64 = result . system = = " x 8 6 _ 6 4 - l i n u x "
|| result . system = = " x 8 6 _ 6 4 - d a r w i n "
|| result . system = = " x 8 6 _ 6 4 - f r e e b s d "
|| result . system = = " x 8 6 _ 6 4 - o p e n b s d "
|| result . system = = " x 8 6 _ 6 4 - s o l a r i s " ;
is64bit = result . system = = " x 8 6 _ 6 4 - l i n u x "
|| result . system = = " x 8 6 _ 6 4 - d a r w i n "
|| result . system = = " x 8 6 _ 6 4 - f r e e b s d "
|| result . system = = " x 8 6 _ 6 4 - o p e n b s d "
|| result . system = = " x 8 6 _ 6 4 - s o l a r i s " ;
isMips = result . system = = " m i p s - l i n u x "
|| result . system = = " m i p s 6 4 e l - l i n u x " ;
isArm = result . system = = " a r m v 5 t e l - l i n u x "
|| result . system = = " a r m v 6 l - l i n u x "
|| result . system = = " a r m v 7 l - l i n u x " ;
# Utility function: allow stdenv to be easily regenerated with
# a different setup script. (See all-packages.nix for an
# example.)
regenerate = stdenvGenerator ;
# For convenience, bring in the library functions in lib/ so
# packages don't have to do that themselves.
inherit lib ;
# For convenience, bring in the library functions in lib/ so
# packages don't have to do that themselves.
inherit lib ;
inherit fetchurlBoot ;
inherit fetchurlBoot ;
inherit overrides ;
}
inherit overrides ;
}
# Propagate any extra attributes. For instance, we use this to
# "lift" packages like curl from the final stdenv for Linux to
# all-packages.nix for that platform (meaning that it has a line
# like curl = if stdenv ? curl then stdenv.curl else ...).
// extraAttrs ;
# Propagate any extra attributes. For instance, we use this to
# "lift" packages like curl from the final stdenv for Linux to
# all-packages.nix for that platform (meaning that it has a line
# like curl = if stdenv ? curl then stdenv.curl else ...).
// extraAttrs ;
} . result ;
in stdenvGenerator ./setup.sh
in result )