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
# explicit overrides of the dynamic linker by callers to gcc/ld
# (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) ''
@ -258,9 +258,9 @@ stdenv.mkDerivation {
# Propagate the wrapped cc so that if you install the wrapper,
# you get tools like gcov, the manpages, etc. as well (including
# 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 != "") ''

View file

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

View file

@ -84,7 +84,7 @@ rec {
mkdir -p $out/nix-support
cp ${script} $out/nix-support/setup-hook
'' + 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 != {}) ''
substituteAll ${script} $out/nix-support/setup-hook
'');

View file

@ -86,7 +86,7 @@ rec {
};})
''
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

View file

@ -33,7 +33,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up
# properly.
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

View file

@ -23,7 +23,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up
# properly.
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

View file

@ -190,7 +190,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up
# properly.
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.
mkdir -p $out/nix-support

View file

@ -202,7 +202,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up
# properly.
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.
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
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.
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" {} \;
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.
cat <<EOF >> $out/nix-support/setup-hook

View file

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

View file

@ -23,7 +23,7 @@ in
*/
collection = {list, name} : runCommand "collection-${name}" {} ''
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}

View file

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

View file

@ -15,5 +15,5 @@ cat "$setup" >> $out/setup
# in stdenv.
mkdir $out/nix-support
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

View file

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