stdenv multiple-outputs: change propagation rules

Now development stuff is propagated from the first output,
and userEnvPkgs from the one with binaries.

Also don't move *.la files (yet). It causes problems, and they're small.

+54 -37
+8 -7
pkgs/build-support/cc-wrapper/default.nix
··· 28 28 29 29 libc_bin = if nativeLibc then null else libc.bin or libc; 30 30 libc_dev = if nativeLibc then null else libc.dev or libc; 31 + libc_lib = if nativeLibc then null else libc.out or libc; 31 32 binutils_bin = if nativeTools then null else binutils.bin or binutils; 32 33 # The wrapper scripts use 'cat', so we may need coreutils. 33 34 coreutils_bin = if nativeTools then null else coreutils.bin or coreutils; ··· 40 41 41 42 preferLocalBuild = true; 42 43 43 - inherit cc shell libc_bin libc_dev binutils_bin coreutils_bin; 44 + inherit cc shell libc_bin libc_dev libc_lib binutils_bin coreutils_bin; 44 45 45 46 passthru = { inherit libc nativeTools nativeLibc nativePrefix; }; 46 47 ··· 58 59 '' 59 60 60 61 + optionalString (!nativeLibc) (if (!stdenv.isDarwin) then '' 61 - dynamicLinker="${libc}/lib/$dynamicLinker" 62 + dynamicLinker="${libc_lib}/lib/$dynamicLinker" 62 63 echo $dynamicLinker > $out/nix-support/dynamic-linker 63 64 64 - if [ -e ${libc}/lib/32/ld-linux.so.2 ]; then 65 - echo ${libc}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 65 + if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then 66 + echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 66 67 fi 67 68 68 69 # The dynamic linker is passed in `ldflagsBefore' to allow ··· 87 88 # compile, because it uses "#include_next <limits.h>" to find the 88 89 # limits.h file in ../includes-fixed. To remedy the problem, 89 90 # another -idirafter is necessary to add that directory again. 90 - echo "-B${libc}/lib/ -idirafter ${libc_dev}/include -idirafter $cc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags 91 + echo "-B${libc_lib}/lib/ -idirafter ${libc_dev}/include -idirafter $cc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags 91 92 92 - echo "-L${libc}/lib" > $out/nix-support/libc-ldflags 93 + echo "-L${libc_lib}/lib" > $out/nix-support/libc-ldflags 93 94 94 - echo "${libc}" > $out/nix-support/orig-libc 95 + echo "${libc_lib}" > $out/nix-support/orig-libc 95 96 '' 96 97 97 98 + (if nativeTools then ''
+29 -15
pkgs/build-support/setup-hooks/multiple-outputs.sh
··· 39 39 _overrideFirst outputMan "man" "doc" "$outputBin" 40 40 _overrideFirst outputInfo "info" "doc" "$outputMan" 41 41 42 - # Make stdenv put propagated*BuildInputs into $outputDev instead of $out 43 - propagateIntoOutput="${!outputDev}" 44 - 45 42 46 43 # Add standard flags to put files into the desired outputs. 47 44 _multioutConfig() { ··· 67 64 68 65 69 66 # Move subpaths that match pattern $1 from under any output/ to the $2 output/ 67 + # Beware: only * ? [..] patterns are accepted. 70 68 _moveToOutput() { 71 69 local patt="$1" 72 70 local dstOut="$2" ··· 108 106 # Move development-only stuff to the desired outputs. 109 107 _multioutDevs() { 110 108 if [ "$outputs" = "out" ] || [ -z "${moveToDev-1}" ]; then return; fi; 111 - echo "Looking for development-only stuff to move between outputs" 109 + echo "Looking for development-only stuff to move to $outputDev" 112 110 _moveToOutput include "${!outputInclude}" 113 111 _moveToOutput lib/pkgconfig "${!outputDev}" 114 - _moveToOutput "lib/*.la" "${!outputDev}" 112 + _moveToOutput share/pkgconfig "${!outputDev}" 115 113 116 - echo "Patching *.pc includedir to output ${!outputInclude}" 117 - for f in "${!outputDev}"/lib/pkgconfig/*.pc; do 114 + # don't move libtool files yet 115 + #_moveToOutput "lib/*.la" "${!outputDev}" 116 + 117 + for f in "${!outputDev}"/{lib,share}/pkgconfig/*.pc; do 118 + echo "Patching '$f' includedir to output ${!outputInclude}" 118 119 sed -i "/^includedir=/s,=\${prefix},=${!outputInclude}," "$f" 119 120 done 120 121 } 121 122 122 - # Make ${!outputDev} propagate other outputs needed for development 123 + # Make the first output (typically "dev") propagate other outputs needed for development. 124 + # Take the first, because that's what one gets when putting the package into buildInputs. 123 125 # Note: during the build, probably only the "native" development packages are useful. 124 126 # With current cross-building setup, all packages are "native" if not cross-building. 125 127 _multioutPropagateDev() { 126 128 if [ "$outputs" = "out" ]; then return; fi; 127 129 128 - if [ "${!outputInclude}" != "$propagateIntoOutput" ]; then 129 - mkdir -p "$propagateIntoOutput"/nix-support 130 - echo -n " ${!outputInclude}" >> "$propagateIntoOutput"/nix-support/propagated-native-build-inputs 131 - fi 132 - if [ "${!outputLib}" != "$propagateIntoOutput" ]; then 133 - mkdir -p "$propagateIntoOutput"/nix-support 134 - echo -n " ${!outputLib}" >> "$propagateIntoOutput"/nix-support/propagated-native-build-inputs 130 + local outputFirst 131 + for outputFirst in $outputs; do 132 + break 133 + done 134 + 135 + # Default value: propagate binaries, includes and libraries 136 + if [[ ! -v "$propagatedOutputs" ]]; then 137 + local po_dirty="$outputBin $outputInclude $outputLib" 138 + propagatedOutputs=`echo "$po_dirty" \ 139 + | tr -s ' ' '\n' | grep -v -F "$outputFirst" \ 140 + | sort -u | tr '\n' ' ' ` 141 + 142 + elif [ -z "$propagatedOutputs" ]; then 143 + return # variable was explicitly set to empty 135 144 fi 145 + 146 + mkdir -p "${!outputFirst}"/nix-support 147 + for output in $propagatedOutputs; do 148 + echo -n " ${!output}" >> "${!outputFirst}"/nix-support/propagated-native-build-inputs 149 + done 136 150 } 137 151
+2 -2
pkgs/development/interpreters/perl/5.20/default.nix
··· 46 46 "-Uinstallusrbinperl" 47 47 "-Dinstallstyle=lib/perl5" 48 48 "-Duseshrplib" 49 - "-Dlocincpth=${libc}/include" 50 - "-Dloclibpth=${libc}/lib" 49 + "-Dlocincpth=${libc.dev or libc}/include" 50 + "-Dloclibpth=${libc.out or libc}/lib" 51 51 ] 52 52 ++ optional enableThreading "-Dusethreads"; 53 53
+1 -1
pkgs/development/libraries/glibc/common.nix
··· 119 119 120 120 installFlags = [ "sysconfdir=$(out)/etc" ]; 121 121 122 - outputs = [ "out" "dev" "bin" "static" ]; 122 + outputs = [ "dev" "out" "bin" "static" ]; 123 123 124 124 buildInputs = [ ] 125 125 ++ stdenv.lib.optionals (cross != null) [ gccCross ]
+14 -12
pkgs/stdenv/generic/setup.sh
··· 712 712 prefix=${!output} runHook fixupOutput 713 713 done 714 714 715 - # Multiple-output derivations mostly choose $dev instead of $out 716 - local prOut="${propagateIntoOutput:-$out}" 715 + 716 + # Propagate build inputs and setup hook into the development output. 717 717 718 718 if [ -n "$propagatedBuildInputs" ]; then 719 - mkdir -p "$prOut/nix-support" 720 - echo "$propagatedBuildInputs" > "$prOut/nix-support/propagated-build-inputs" 719 + mkdir -p "${!outputDev}/nix-support" 720 + echo "$propagatedBuildInputs" > "${!outputDev}/nix-support/propagated-build-inputs" 721 721 fi 722 722 723 723 if [ -n "$propagatedNativeBuildInputs" ]; then 724 - mkdir -p "$prOut/nix-support" 725 - echo "$propagatedNativeBuildInputs" > "$prOut/nix-support/propagated-native-build-inputs" 724 + mkdir -p "${!outputDev}/nix-support" 725 + echo "$propagatedNativeBuildInputs" > "${!outputDev}/nix-support/propagated-native-build-inputs" 726 726 fi 727 727 728 - if [ -n "$propagatedUserEnvPkgs" ]; then 729 - mkdir -p "$prOut/nix-support" 730 - echo "$propagatedUserEnvPkgs" > "$prOut/nix-support/propagated-user-env-packages" 728 + if [ -n "$setupHook" ]; then 729 + mkdir -p "${!outputDev}/nix-support" 730 + substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook" 731 731 fi 732 732 733 - if [ -n "$setupHook" ]; then 734 - mkdir -p "$prOut/nix-support" 735 - substituteAll "$setupHook" "$prOut/nix-support/setup-hook" 733 + # Propagate user-env packages into the output with binaries, TODO? 734 + 735 + if [ -n "$propagatedUserEnvPkgs" ]; then 736 + mkdir -p "${!outputBin}/nix-support" 737 + echo "$propagatedUserEnvPkgs" > "${!outputBin}/nix-support/propagated-user-env-packages" 736 738 fi 737 739 738 740 runHook postFixup