Skip to content

Commit

Permalink
stdenv: Store one package per line in nix-support/propagated-*
Browse files Browse the repository at this point in the history
This makes those files a bit easier to read. Also, for what it's worth,
it brings us one baby step closer to handling spaces in store paths.

Also, I optimized handling of many transitive deps with read. Probably,
not very beneficial, but nice to enforce the pkg-per-line structure.
Doing so let me find much dubious code and fix it.

Two misc notes:

 - `propagated-user-env-packages` also needed to be adjusted as
   sometimes it is copied to/from the propagated input files.

 - `local fd` should ensure that file descriptors aren't clobbered
   during recursion.
  • Loading branch information
Ericson2314 committed Jul 10, 2017
1 parent f385e22 commit 3cb745d
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 22 deletions.
4 changes: 2 additions & 2 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,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).
echo ${cc} ${cc.man or ""} ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages
printLines ${cc} ${cc.man or ""} ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages
echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs
printLines ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs
''

+ optionalString (targetPlatform.isSunOS && nativePrefix != "") ''
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/gcc-wrapper-old/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
echo $gcc $binutils $libc $libc_bin > $out/nix-support/propagated-user-env-packages
printLines $gcc $binutils $libc $libc_bin > $out/nix-support/propagated-user-env-packages
fi
2 changes: 1 addition & 1 deletion pkgs/build-support/setup-hooks/multiple-outputs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ _multioutPropagateDev() {

mkdir -p "${!propagaterOutput}"/nix-support
for output in $propagatedBuildOutputs; do
echo -n " ${!output}" >> "${!propagaterOutput}"/nix-support/$propagatedBuildInputsFile
echo "${!output}" >> "${!propagaterOutput}"/nix-support/$propagatedBuildInputsFile
done
}

2 changes: 1 addition & 1 deletion pkgs/build-support/trivial-builders.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ rec {
mkdir -p $out/nix-support
cp ${script} $out/nix-support/setup-hook
'' + lib.optionalString (deps != []) ''
echo ${toString deps} > $out/nix-support/propagated-native-build-inputs
printLines ${toString deps} > $out/nix-support/propagated-native-build-inputs
'' + lib.optionalString (substitutions != {}) ''
substituteAll ${script} $out/nix-support/setup-hook
'');
Expand Down
2 changes: 1 addition & 1 deletion pkgs/desktops/kde-4.14/kde-package/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ rec {
};})
''
mkdir -pv $out/nix-support
echo "${toString list}" | tee $out/nix-support/propagated-user-env-packages
printLines ${toString list} | tee $out/nix-support/propagated-user-env-packages
'';

# Given manifest module data, return the module
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/openjdk-darwin/8.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up
# properly.
mkdir -p $out/nix-support
echo -n "${setJavaClassPath}" > $out/nix-support/propagated-native-build-inputs
printLines ${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
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/openjdk-darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up
# properly.
mkdir -p $out/nix-support
echo -n "${setJavaClassPath}" > $out/nix-support/propagated-native-build-inputs
printLines ${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
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/openjdk/7.nix
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up
# properly.
mkdir -p $jre/nix-support
echo -n "${setJavaClassPath}" > $jre/nix-support/propagated-native-build-inputs
printLines ${setJavaClassPath} > $jre/nix-support/propagated-native-build-inputs
# Set JAVA_HOME automatically.
mkdir -p $out/nix-support
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/openjdk/8.nix
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ let
# any package that depends on the JRE has $CLASSPATH set up
# properly.
mkdir -p $jre/nix-support
echo -n "${setJavaClassPath}" > $jre/nix-support/propagated-native-build-inputs
printLines ${setJavaClassPath} > $jre/nix-support/propagated-native-build-inputs
# Set JAVA_HOME automatically.
mkdir -p $out/nix-support
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/oraclejdk/jdk-linux-base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ let result = stdenv.mkDerivation rec {
ln -s $jrePath/lib/${architecture}/libnpjp2.so $jrePath/lib/${architecture}/plugins
mkdir -p $out/nix-support
echo -n "${setJavaClassPath}" > $out/nix-support/propagated-native-build-inputs
printLines ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs
# Set JAVA_HOME automatically.
cat <<EOF >> $out/nix-support/setup-hook
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/zulu/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ in stdenv.mkDerivation rec {
find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \;
mkdir -p $out/nix-support
echo -n "${setJavaClassPath}" > $out/nix-support/propagated-native-build-inputs
printLines ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs
# Set JAVA_HOME automatically.
cat <<EOF >> $out/nix-support/setup-hook
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/haskell-modules/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ stdenv.mkDerivation ({
${optionalString isGhcjs ''
for exeDir in "$out/bin/"*.jsexe; do
exe="''${exeDir%.jsexe}"
printf '%s\n' '#!${nodejs}/bin/node' > "$exe"
printLines '#!${nodejs}/bin/node' > "$exe"
cat "$exeDir/all.js" >> "$exe"
chmod +x "$exe"
done
Expand Down
2 changes: 1 addition & 1 deletion pkgs/misc/misc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ in
*/
collection = {list, name} : runCommand "collection-${name}" {} ''
mkdir -p $out/nix-support
echo ${builtins.toString list} > $out/nix-support/propagated-user-env-packages
printLines ${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}
Expand Down
5 changes: 3 additions & 2 deletions pkgs/stdenv/generic/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export PATH=
for i in $initialPath; do
if [ "$i" = / ]; then i=; fi
PATH=$PATH${PATH:+:}$i/bin
Expand All @@ -15,4 +14,6 @@ cat "$setup" >> $out/setup
# Allow the user to install stdenv using nix-env and get the packages
# in stdenv.
mkdir $out/nix-support
echo $propagatedUserEnvPkgs > $out/nix-support/propagated-user-env-packages
if [ "$propagatedUserEnvPkgs" ]; then
printf '%s\n' $propagatedUserEnvPkgs > $out/nix-support/propagated-user-env-packages
fi
20 changes: 14 additions & 6 deletions pkgs/stdenv/generic/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ isScript() {
if [[ "$magic" =~ \#! ]]; then return 0; else return 1; fi
}

# printf unfortunately will print a trailing newline regardless
printLines() {
[[ $# -gt 0 ]] || return 0
printf '%s\n' "$@"
}

######################################################################
# Initialisation.
Expand Down Expand Up @@ -300,9 +305,12 @@ findInputs() {
fi

if [ -f "$pkg/nix-support/$propagatedBuildInputsFile" ]; then
for i in $(cat "$pkg/nix-support/$propagatedBuildInputsFile"); do
findInputs "$i" $var $propagatedBuildInputsFile
local fd pkgNext
exec {fd}<"$pkg/nix-support/$propagatedBuildInputsFile"
while IFS= read -r -u $fd pkgNext; do
findInputs "$pkgNext" $var $propagatedBuildInputsFile
done
exec {fd}<&-
fi
}

Expand Down Expand Up @@ -794,17 +802,17 @@ fixupPhase() {
fi
if [ -n "$propagated" ]; then
mkdir -p "${!outputDev}/nix-support"
echo "$propagated" > "${!outputDev}/nix-support/propagated-native-build-inputs"
printLines $propagated > "${!outputDev}/nix-support/propagated-native-build-inputs"
fi
else
if [ -n "$propagatedBuildInputs" ]; then
mkdir -p "${!outputDev}/nix-support"
echo "$propagatedBuildInputs" > "${!outputDev}/nix-support/propagated-build-inputs"
printLines $propagatedBuildInputs > "${!outputDev}/nix-support/propagated-build-inputs"
fi

if [ -n "$propagatedNativeBuildInputs" ]; then
mkdir -p "${!outputDev}/nix-support"
echo "$propagatedNativeBuildInputs" > "${!outputDev}/nix-support/propagated-native-build-inputs"
printLines $propagatedNativeBuildInputs > "${!outputDev}/nix-support/propagated-native-build-inputs"
fi
fi

Expand All @@ -817,7 +825,7 @@ fixupPhase() {

if [ -n "$propagatedUserEnvPkgs" ]; then
mkdir -p "${!outputBin}/nix-support"
echo "$propagatedUserEnvPkgs" > "${!outputBin}/nix-support/propagated-user-env-packages"
printLines $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages"
fi

runHook postFixup
Expand Down

0 comments on commit 3cb745d

Please sign in to comment.