Merge pull request #27650 from obsidiansystems/unbreak-stdenv

Unbreak stdenv
This commit is contained in:
John Ericson 2017-07-26 13:23:12 -04:00 committed by GitHub
commit 8ce4780eff
16 changed files with 52 additions and 40 deletions

View File

@ -190,7 +190,7 @@ stdenv.mkDerivation {
# The dynamic linker is passed in `ldflagsBefore' to allow # The dynamic linker is passed in `ldflagsBefore' to allow
# explicit overrides of the dynamic linker by callers to gcc/ld # explicit overrides of the dynamic linker by callers to gcc/ld
# (the *last* value counts, so ours should come first). # (the *last* value counts, so ours should come first).
printLines "''${ldflagsBefore[@]}" > $out/nix-support/libc-ldflags-before printWords "''${ldflagsBefore[@]}" > $out/nix-support/libc-ldflags-before
'') '')
+ optionalString (libc != null) '' + optionalString (libc != null) ''
@ -258,9 +258,9 @@ stdenv.mkDerivation {
# Propagate the wrapped cc so that if you install the wrapper, # Propagate the wrapped cc so that if you install the wrapper,
# you get tools like gcov, the manpages, etc. as well (including # you get tools like gcov, the manpages, etc. as well (including
# for binutils and Glibc). # for binutils and Glibc).
printLines ${cc} ${cc.man or ""} ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages printWords ${cc} ${cc.man or ""} ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages
printLines ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs printWords ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs
'' ''
+ optionalString (targetPlatform.isSunOS && nativePrefix != "") '' + optionalString (targetPlatform.isSunOS && nativePrefix != "") ''

View File

@ -54,7 +54,7 @@ do
if if
PATH=$_PATH type -p "@binPrefix@$CMD" > /dev/null PATH=$_PATH type -p "@binPrefix@$CMD" > /dev/null
then then
export "${ENV_PREFIX}${CMD^^}=@binPrefix@${CMD}"; export "${ENV_PREFIX}$(echo "$CMD" | tr "[:lower:]" "[:upper:]")=@binPrefix@${CMD}";
fi fi
done done

View File

@ -211,5 +211,5 @@ cp -p $utils $out/nix-support/utils.sh
# tools like gcov, the manpages, etc. as well (including for binutils # tools like gcov, the manpages, etc. as well (including for binutils
# and Glibc). # and Glibc).
if test -z "$nativeTools"; then if test -z "$nativeTools"; then
printLines $gcc $binutils $libc $libc_bin > $out/nix-support/propagated-user-env-packages printWords $gcc $binutils $libc $libc_bin > $out/nix-support/propagated-user-env-packages
fi fi

View File

@ -84,7 +84,7 @@ rec {
mkdir -p $out/nix-support mkdir -p $out/nix-support
cp ${script} $out/nix-support/setup-hook cp ${script} $out/nix-support/setup-hook
'' + lib.optionalString (deps != []) '' '' + lib.optionalString (deps != []) ''
printLines ${toString deps} > $out/nix-support/propagated-native-build-inputs printWords ${toString deps} > $out/nix-support/propagated-native-build-inputs
'' + lib.optionalString (substitutions != {}) '' '' + lib.optionalString (substitutions != {}) ''
substituteAll ${script} $out/nix-support/setup-hook substituteAll ${script} $out/nix-support/setup-hook
''); '');

View File

@ -86,7 +86,7 @@ rec {
};}) };})
'' ''
mkdir -pv $out/nix-support mkdir -pv $out/nix-support
printLines ${toString list} | tee $out/nix-support/propagated-user-env-packages printWords ${toString list} | tee $out/nix-support/propagated-user-env-packages
''; '';
# Given manifest module data, return the module # Given manifest module data, return the module

View File

@ -33,7 +33,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up # any package that depends on the JRE has $CLASSPATH set up
# properly. # properly.
mkdir -p $out/nix-support mkdir -p $out/nix-support
printLines ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs printWords ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs
install_name_tool -change /usr/X11/lib/libfreetype.6.dylib ${freetype}/lib/libfreetype.6.dylib $out/jre/lib/libfontmanager.dylib install_name_tool -change /usr/X11/lib/libfreetype.6.dylib ${freetype}/lib/libfreetype.6.dylib $out/jre/lib/libfontmanager.dylib

View File

@ -23,7 +23,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up # any package that depends on the JRE has $CLASSPATH set up
# properly. # properly.
mkdir -p $out/nix-support mkdir -p $out/nix-support
printLines ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs printWords ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs
install_name_tool -change /usr/X11/lib/libfreetype.6.dylib ${freetype}/lib/libfreetype.6.dylib $out/jre/lib/libfontmanager.dylib install_name_tool -change /usr/X11/lib/libfreetype.6.dylib ${freetype}/lib/libfreetype.6.dylib $out/jre/lib/libfontmanager.dylib

View File

@ -190,7 +190,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up # any package that depends on the JRE has $CLASSPATH set up
# properly. # properly.
mkdir -p $jre/nix-support mkdir -p $jre/nix-support
printLines ${setJavaClassPath} > $jre/nix-support/propagated-native-build-inputs printWords ${setJavaClassPath} > $jre/nix-support/propagated-native-build-inputs
# Set JAVA_HOME automatically. # Set JAVA_HOME automatically.
mkdir -p $out/nix-support mkdir -p $out/nix-support

View File

@ -202,7 +202,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up # any package that depends on the JRE has $CLASSPATH set up
# properly. # properly.
mkdir -p $jre/nix-support mkdir -p $jre/nix-support
printLines ${setJavaClassPath} > $jre/nix-support/propagated-native-build-inputs printWords ${setJavaClassPath} > $jre/nix-support/propagated-native-build-inputs
# Set JAVA_HOME automatically. # Set JAVA_HOME automatically.
mkdir -p $out/nix-support mkdir -p $out/nix-support

View File

@ -165,7 +165,7 @@ let result = stdenv.mkDerivation rec {
ln -s $jrePath/lib/${architecture}/libnpjp2.so $jrePath/lib/${architecture}/plugins ln -s $jrePath/lib/${architecture}/libnpjp2.so $jrePath/lib/${architecture}/plugins
mkdir -p $out/nix-support mkdir -p $out/nix-support
printLines ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs printWords ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs
# Set JAVA_HOME automatically. # Set JAVA_HOME automatically.
cat <<EOF >> $out/nix-support/setup-hook cat <<EOF >> $out/nix-support/setup-hook

View File

@ -54,7 +54,7 @@ in stdenv.mkDerivation rec {
find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \; find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \;
mkdir -p $out/nix-support mkdir -p $out/nix-support
printLines ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs printWords ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs
# Set JAVA_HOME automatically. # Set JAVA_HOME automatically.
cat <<EOF >> $out/nix-support/setup-hook cat <<EOF >> $out/nix-support/setup-hook

View File

@ -211,7 +211,7 @@ stdenv.mkDerivation ({
configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags" configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags"
# nativePkgs defined in stdenv/setup.hs # nativePkgs defined in stdenv/setup.hs
for p in "''${!nativePkgs[@]}"; do for p in "''${nativePkgs[@]}"; do
if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then
cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/ cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/
continue continue
@ -311,7 +311,7 @@ stdenv.mkDerivation ({
${optionalString isGhcjs '' ${optionalString isGhcjs ''
for exeDir in "$out/bin/"*.jsexe; do for exeDir in "$out/bin/"*.jsexe; do
exe="''${exeDir%.jsexe}" exe="''${exeDir%.jsexe}"
printLines '#!${nodejs}/bin/node' > "$exe" printWords '#!${nodejs}/bin/node' > "$exe"
cat "$exeDir/all.js" >> "$exe" cat "$exeDir/all.js" >> "$exe"
chmod +x "$exe" chmod +x "$exe"
done done

View File

@ -23,7 +23,7 @@ in
*/ */
collection = {list, name} : runCommand "collection-${name}" {} '' collection = {list, name} : runCommand "collection-${name}" {} ''
mkdir -p $out/nix-support mkdir -p $out/nix-support
printLines ${builtins.toString list} > $out/nix-support/propagated-user-env-packages printWords ${builtins.toString list} > $out/nix-support/propagated-user-env-packages
''; '';
/* creates a derivation symlinking references C/C++ libs into one include and lib directory called $out/cdt-envs/${name} /* creates a derivation symlinking references C/C++ libs into one include and lib directory called $out/cdt-envs/${name}

View File

@ -18,14 +18,14 @@ postInstall() {
for r in $requires; do for r in $requires; do
if test -n "$crossConfig"; then if test -n "$crossConfig"; then
for p in "${!crossPkgs[@]}"; do for p in "${crossPkgs[@]}"; do
if test -e $p/lib/pkgconfig/$r.pc; then if test -e $p/lib/pkgconfig/$r.pc; then
echo " found requisite $r in $p" echo " found requisite $r in $p"
propagatedBuildInputs="$propagatedBuildInputs $p" propagatedBuildInputs="$propagatedBuildInputs $p"
fi fi
done done
else else
for p in "${!nativePkgs[@]}"; do for p in "${nativePkgs[@]}"; do
if test -e $p/lib/pkgconfig/$r.pc; then if test -e $p/lib/pkgconfig/$r.pc; then
echo " found requisite $r in $p" echo " found requisite $r in $p"
propagatedNativeBuildInputs="$propagatedNativeBuildInputs $p" propagatedNativeBuildInputs="$propagatedNativeBuildInputs $p"

View File

@ -15,5 +15,5 @@ cat "$setup" >> $out/setup
# in stdenv. # in stdenv.
mkdir $out/nix-support mkdir $out/nix-support
if [ "$propagatedUserEnvPkgs" ]; then if [ "$propagatedUserEnvPkgs" ]; then
printf '%s\n' $propagatedUserEnvPkgs > $out/nix-support/propagated-user-env-packages printf '%s ' $propagatedUserEnvPkgs > $out/nix-support/propagated-user-env-packages
fi fi

View File

@ -17,9 +17,10 @@ runHook() {
shift shift
local var="$hookName" local var="$hookName"
if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi
local -n var
local varRef="$var[@]"
local hook local hook
for hook in "_callImplicitHook 0 $hookName" "${var[@]}"; do for hook in "_callImplicitHook 0 $hookName" "${!varRef}"; do
_eval "$hook" "$@" _eval "$hook" "$@"
done done
return 0 return 0
@ -33,9 +34,10 @@ runOneHook() {
shift shift
local var="$hookName" local var="$hookName"
if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi
local -n var
local varRef="$var[@]"
local hook local hook
for hook in "_callImplicitHook 1 $hookName" "${var[@]}"; do for hook in "_callImplicitHook 1 $hookName" "${!varRef}"; do
if _eval "$hook" "$@"; then if _eval "$hook" "$@"; then
return 0 return 0
fi fi
@ -210,6 +212,11 @@ printLines() {
printf '%s\n' "$@" printf '%s\n' "$@"
} }
printWords() {
[[ "$#" -gt 0 ]] || return 0
printf '%s ' "$@"
}
###################################################################### ######################################################################
# Initialisation. # Initialisation.
@ -266,12 +273,19 @@ runHook addInputsHook
findInputs() { findInputs() {
local pkg="$1" local pkg="$1"
local var="$2" local var="$2"
local -n varDeref="$var"
local propagatedBuildInputsFile="$3" local propagatedBuildInputsFile="$3"
# Stop if we've already added this one # TODO(@Ericson2314): Restore using associative array once Darwin
[[ -z "${varDeref["$pkg"]}" ]] || return 0 # nix-shell doesn't use impure bash. This should replace the O(n)
varDeref["$pkg"]=1 # case with an O(1) hash map lookup, assuming bash is implemented
# well :D.
local varRef="$var[*]"
case "${!varRef}" in
*" $pkg "*) return 0 ;;
esac
eval "$var"'+=("$pkg")'
if ! [ -e "$pkg" ]; then if ! [ -e "$pkg" ]; then
echo "build input $pkg does not exist" >&2 echo "build input $pkg does not exist" >&2
@ -291,31 +305,29 @@ findInputs() {
fi fi
if [ -f "$pkg/nix-support/$propagatedBuildInputsFile" ]; then if [ -f "$pkg/nix-support/$propagatedBuildInputsFile" ]; then
local fd pkgNext local pkgNext
exec {fd}<"$pkg/nix-support/$propagatedBuildInputsFile" for pkgNext in $(< "$pkg/nix-support/$propagatedBuildInputsFile"); do
while IFS= read -r -u $fd pkgNext; do
findInputs "$pkgNext" "$var" "$propagatedBuildInputsFile" findInputs "$pkgNext" "$var" "$propagatedBuildInputsFile"
done done
exec {fd}<&-
fi fi
} }
if [ -z "$crossConfig" ]; then if [ -z "$crossConfig" ]; then
# Not cross-compiling - both buildInputs (and variants like propagatedBuildInputs) # Not cross-compiling - both buildInputs (and variants like propagatedBuildInputs)
# are handled identically to nativeBuildInputs # are handled identically to nativeBuildInputs
declare -gA nativePkgs declare -a nativePkgs
for i in $nativeBuildInputs $buildInputs \ for i in $nativeBuildInputs $buildInputs \
$defaultNativeBuildInputs $defaultBuildInputs \ $defaultNativeBuildInputs $defaultBuildInputs \
$propagatedNativeBuildInputs $propagatedBuildInputs; do $propagatedNativeBuildInputs $propagatedBuildInputs; do
findInputs "$i" nativePkgs propagated-native-build-inputs findInputs "$i" nativePkgs propagated-native-build-inputs
done done
else else
declare -gA crossPkgs declare -a crossPkgs
for i in $buildInputs $defaultBuildInputs $propagatedBuildInputs; do for i in $buildInputs $defaultBuildInputs $propagatedBuildInputs; do
findInputs "$i" crossPkgs propagated-build-inputs findInputs "$i" crossPkgs propagated-build-inputs
done done
declare -gA nativePkgs declare -a nativePkgs
for i in $nativeBuildInputs $defaultNativeBuildInputs $propagatedNativeBuildInputs; do for i in $nativeBuildInputs $defaultNativeBuildInputs $propagatedNativeBuildInputs; do
findInputs "$i" nativePkgs propagated-native-build-inputs findInputs "$i" nativePkgs propagated-native-build-inputs
done done
@ -331,7 +343,7 @@ _addToNativeEnv() {
runHook envHook "$pkg" runHook envHook "$pkg"
} }
for i in "${!nativePkgs[@]}"; do for i in "${nativePkgs[@]}"; do
_addToNativeEnv "$i" _addToNativeEnv "$i"
done done
@ -342,7 +354,7 @@ _addToCrossEnv() {
runHook crossEnvHook "$pkg" runHook crossEnvHook "$pkg"
} }
for i in "${!crossPkgs[@]}"; do for i in "${crossPkgs[@]}"; do
_addToCrossEnv "$i" _addToCrossEnv "$i"
done done
@ -814,19 +826,19 @@ fixupPhase() {
if [ -n "$propagated" ]; then if [ -n "$propagated" ]; then
mkdir -p "${!outputDev}/nix-support" mkdir -p "${!outputDev}/nix-support"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
printLines $propagated > "${!outputDev}/nix-support/propagated-native-build-inputs" printWords $propagated > "${!outputDev}/nix-support/propagated-native-build-inputs"
fi fi
else else
if [ -n "$propagatedBuildInputs" ]; then if [ -n "$propagatedBuildInputs" ]; then
mkdir -p "${!outputDev}/nix-support" mkdir -p "${!outputDev}/nix-support"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
printLines $propagatedBuildInputs > "${!outputDev}/nix-support/propagated-build-inputs" printWords $propagatedBuildInputs > "${!outputDev}/nix-support/propagated-build-inputs"
fi fi
if [ -n "$propagatedNativeBuildInputs" ]; then if [ -n "$propagatedNativeBuildInputs" ]; then
mkdir -p "${!outputDev}/nix-support" mkdir -p "${!outputDev}/nix-support"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
printLines $propagatedNativeBuildInputs > "${!outputDev}/nix-support/propagated-native-build-inputs" printWords $propagatedNativeBuildInputs > "${!outputDev}/nix-support/propagated-native-build-inputs"
fi fi
fi fi
@ -840,7 +852,7 @@ fixupPhase() {
if [ -n "$propagatedUserEnvPkgs" ]; then if [ -n "$propagatedUserEnvPkgs" ]; then
mkdir -p "${!outputBin}/nix-support" mkdir -p "${!outputBin}/nix-support"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
printLines $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages" printWords $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages"
fi fi
runHook postFixup runHook postFixup