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.
This commit is contained in:
parent
bf414c9d4f
commit
d484c392aa
@ -28,6 +28,7 @@ let
|
|||||||
|
|
||||||
libc_bin = if nativeLibc then null else libc.bin or libc;
|
libc_bin = if nativeLibc then null else libc.bin or libc;
|
||||||
libc_dev = if nativeLibc then null else libc.dev or libc;
|
libc_dev = if nativeLibc then null else libc.dev or libc;
|
||||||
|
libc_lib = if nativeLibc then null else libc.out or libc;
|
||||||
binutils_bin = if nativeTools then null else binutils.bin or binutils;
|
binutils_bin = if nativeTools then null else binutils.bin or binutils;
|
||||||
# The wrapper scripts use 'cat', so we may need coreutils.
|
# The wrapper scripts use 'cat', so we may need coreutils.
|
||||||
coreutils_bin = if nativeTools then null else coreutils.bin or coreutils;
|
coreutils_bin = if nativeTools then null else coreutils.bin or coreutils;
|
||||||
@ -40,7 +41,7 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
|
|
||||||
inherit cc shell libc_bin libc_dev binutils_bin coreutils_bin;
|
inherit cc shell libc_bin libc_dev libc_lib binutils_bin coreutils_bin;
|
||||||
|
|
||||||
passthru = { inherit libc nativeTools nativeLibc nativePrefix; };
|
passthru = { inherit libc nativeTools nativeLibc nativePrefix; };
|
||||||
|
|
||||||
@ -58,11 +59,11 @@ stdenv.mkDerivation {
|
|||||||
''
|
''
|
||||||
|
|
||||||
+ optionalString (!nativeLibc) (if (!stdenv.isDarwin) then ''
|
+ optionalString (!nativeLibc) (if (!stdenv.isDarwin) then ''
|
||||||
dynamicLinker="${libc}/lib/$dynamicLinker"
|
dynamicLinker="${libc_lib}/lib/$dynamicLinker"
|
||||||
echo $dynamicLinker > $out/nix-support/dynamic-linker
|
echo $dynamicLinker > $out/nix-support/dynamic-linker
|
||||||
|
|
||||||
if [ -e ${libc}/lib/32/ld-linux.so.2 ]; then
|
if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then
|
||||||
echo ${libc}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
|
echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The dynamic linker is passed in `ldflagsBefore' to allow
|
# The dynamic linker is passed in `ldflagsBefore' to allow
|
||||||
@ -87,11 +88,11 @@ stdenv.mkDerivation {
|
|||||||
# compile, because it uses "#include_next <limits.h>" to find the
|
# compile, because it uses "#include_next <limits.h>" to find the
|
||||||
# limits.h file in ../includes-fixed. To remedy the problem,
|
# limits.h file in ../includes-fixed. To remedy the problem,
|
||||||
# another -idirafter is necessary to add that directory again.
|
# another -idirafter is necessary to add that directory again.
|
||||||
echo "-B${libc}/lib/ -idirafter ${libc_dev}/include -idirafter $cc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
|
echo "-B${libc_lib}/lib/ -idirafter ${libc_dev}/include -idirafter $cc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
|
||||||
|
|
||||||
echo "-L${libc}/lib" > $out/nix-support/libc-ldflags
|
echo "-L${libc_lib}/lib" > $out/nix-support/libc-ldflags
|
||||||
|
|
||||||
echo "${libc}" > $out/nix-support/orig-libc
|
echo "${libc_lib}" > $out/nix-support/orig-libc
|
||||||
''
|
''
|
||||||
|
|
||||||
+ (if nativeTools then ''
|
+ (if nativeTools then ''
|
||||||
|
@ -39,9 +39,6 @@ _overrideFirst outputDoc "doc" "out"
|
|||||||
_overrideFirst outputMan "man" "doc" "$outputBin"
|
_overrideFirst outputMan "man" "doc" "$outputBin"
|
||||||
_overrideFirst outputInfo "info" "doc" "$outputMan"
|
_overrideFirst outputInfo "info" "doc" "$outputMan"
|
||||||
|
|
||||||
# Make stdenv put propagated*BuildInputs into $outputDev instead of $out
|
|
||||||
propagateIntoOutput="${!outputDev}"
|
|
||||||
|
|
||||||
|
|
||||||
# Add standard flags to put files into the desired outputs.
|
# Add standard flags to put files into the desired outputs.
|
||||||
_multioutConfig() {
|
_multioutConfig() {
|
||||||
@ -67,6 +64,7 @@ NIX_NO_SELF_RPATH=1
|
|||||||
|
|
||||||
|
|
||||||
# Move subpaths that match pattern $1 from under any output/ to the $2 output/
|
# Move subpaths that match pattern $1 from under any output/ to the $2 output/
|
||||||
|
# Beware: only * ? [..] patterns are accepted.
|
||||||
_moveToOutput() {
|
_moveToOutput() {
|
||||||
local patt="$1"
|
local patt="$1"
|
||||||
local dstOut="$2"
|
local dstOut="$2"
|
||||||
@ -108,30 +106,46 @@ _multioutDocs() {
|
|||||||
# Move development-only stuff to the desired outputs.
|
# Move development-only stuff to the desired outputs.
|
||||||
_multioutDevs() {
|
_multioutDevs() {
|
||||||
if [ "$outputs" = "out" ] || [ -z "${moveToDev-1}" ]; then return; fi;
|
if [ "$outputs" = "out" ] || [ -z "${moveToDev-1}" ]; then return; fi;
|
||||||
echo "Looking for development-only stuff to move between outputs"
|
echo "Looking for development-only stuff to move to $outputDev"
|
||||||
_moveToOutput include "${!outputInclude}"
|
_moveToOutput include "${!outputInclude}"
|
||||||
_moveToOutput lib/pkgconfig "${!outputDev}"
|
_moveToOutput lib/pkgconfig "${!outputDev}"
|
||||||
_moveToOutput "lib/*.la" "${!outputDev}"
|
_moveToOutput share/pkgconfig "${!outputDev}"
|
||||||
|
|
||||||
echo "Patching *.pc includedir to output ${!outputInclude}"
|
# don't move libtool files yet
|
||||||
for f in "${!outputDev}"/lib/pkgconfig/*.pc; do
|
#_moveToOutput "lib/*.la" "${!outputDev}"
|
||||||
|
|
||||||
|
for f in "${!outputDev}"/{lib,share}/pkgconfig/*.pc; do
|
||||||
|
echo "Patching '$f' includedir to output ${!outputInclude}"
|
||||||
sed -i "/^includedir=/s,=\${prefix},=${!outputInclude}," "$f"
|
sed -i "/^includedir=/s,=\${prefix},=${!outputInclude}," "$f"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make ${!outputDev} propagate other outputs needed for development
|
# Make the first output (typically "dev") propagate other outputs needed for development.
|
||||||
|
# Take the first, because that's what one gets when putting the package into buildInputs.
|
||||||
# Note: during the build, probably only the "native" development packages are useful.
|
# Note: during the build, probably only the "native" development packages are useful.
|
||||||
# With current cross-building setup, all packages are "native" if not cross-building.
|
# With current cross-building setup, all packages are "native" if not cross-building.
|
||||||
_multioutPropagateDev() {
|
_multioutPropagateDev() {
|
||||||
if [ "$outputs" = "out" ]; then return; fi;
|
if [ "$outputs" = "out" ]; then return; fi;
|
||||||
|
|
||||||
if [ "${!outputInclude}" != "$propagateIntoOutput" ]; then
|
local outputFirst
|
||||||
mkdir -p "$propagateIntoOutput"/nix-support
|
for outputFirst in $outputs; do
|
||||||
echo -n " ${!outputInclude}" >> "$propagateIntoOutput"/nix-support/propagated-native-build-inputs
|
break
|
||||||
fi
|
done
|
||||||
if [ "${!outputLib}" != "$propagateIntoOutput" ]; then
|
|
||||||
mkdir -p "$propagateIntoOutput"/nix-support
|
# Default value: propagate binaries, includes and libraries
|
||||||
echo -n " ${!outputLib}" >> "$propagateIntoOutput"/nix-support/propagated-native-build-inputs
|
if [[ ! -v "$propagatedOutputs" ]]; then
|
||||||
|
local po_dirty="$outputBin $outputInclude $outputLib"
|
||||||
|
propagatedOutputs=`echo "$po_dirty" \
|
||||||
|
| tr -s ' ' '\n' | grep -v -F "$outputFirst" \
|
||||||
|
| sort -u | tr '\n' ' ' `
|
||||||
|
|
||||||
|
elif [ -z "$propagatedOutputs" ]; then
|
||||||
|
return # variable was explicitly set to empty
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mkdir -p "${!outputFirst}"/nix-support
|
||||||
|
for output in $propagatedOutputs; do
|
||||||
|
echo -n " ${!output}" >> "${!outputFirst}"/nix-support/propagated-native-build-inputs
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ stdenv.mkDerivation rec {
|
|||||||
"-Uinstallusrbinperl"
|
"-Uinstallusrbinperl"
|
||||||
"-Dinstallstyle=lib/perl5"
|
"-Dinstallstyle=lib/perl5"
|
||||||
"-Duseshrplib"
|
"-Duseshrplib"
|
||||||
"-Dlocincpth=${libc}/include"
|
"-Dlocincpth=${libc.dev or libc}/include"
|
||||||
"-Dloclibpth=${libc}/lib"
|
"-Dloclibpth=${libc.out or libc}/lib"
|
||||||
]
|
]
|
||||||
++ optional enableThreading "-Dusethreads";
|
++ optional enableThreading "-Dusethreads";
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ stdenv.mkDerivation ({
|
|||||||
|
|
||||||
installFlags = [ "sysconfdir=$(out)/etc" ];
|
installFlags = [ "sysconfdir=$(out)/etc" ];
|
||||||
|
|
||||||
outputs = [ "out" "dev" "bin" "static" ];
|
outputs = [ "dev" "out" "bin" "static" ];
|
||||||
|
|
||||||
buildInputs = [ ]
|
buildInputs = [ ]
|
||||||
++ stdenv.lib.optionals (cross != null) [ gccCross ]
|
++ stdenv.lib.optionals (cross != null) [ gccCross ]
|
||||||
|
@ -712,27 +712,29 @@ fixupPhase() {
|
|||||||
prefix=${!output} runHook fixupOutput
|
prefix=${!output} runHook fixupOutput
|
||||||
done
|
done
|
||||||
|
|
||||||
# Multiple-output derivations mostly choose $dev instead of $out
|
|
||||||
local prOut="${propagateIntoOutput:-$out}"
|
# Propagate build inputs and setup hook into the development output.
|
||||||
|
|
||||||
if [ -n "$propagatedBuildInputs" ]; then
|
if [ -n "$propagatedBuildInputs" ]; then
|
||||||
mkdir -p "$prOut/nix-support"
|
mkdir -p "${!outputDev}/nix-support"
|
||||||
echo "$propagatedBuildInputs" > "$prOut/nix-support/propagated-build-inputs"
|
echo "$propagatedBuildInputs" > "${!outputDev}/nix-support/propagated-build-inputs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$propagatedNativeBuildInputs" ]; then
|
if [ -n "$propagatedNativeBuildInputs" ]; then
|
||||||
mkdir -p "$prOut/nix-support"
|
mkdir -p "${!outputDev}/nix-support"
|
||||||
echo "$propagatedNativeBuildInputs" > "$prOut/nix-support/propagated-native-build-inputs"
|
echo "$propagatedNativeBuildInputs" > "${!outputDev}/nix-support/propagated-native-build-inputs"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$propagatedUserEnvPkgs" ]; then
|
|
||||||
mkdir -p "$prOut/nix-support"
|
|
||||||
echo "$propagatedUserEnvPkgs" > "$prOut/nix-support/propagated-user-env-packages"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$setupHook" ]; then
|
if [ -n "$setupHook" ]; then
|
||||||
mkdir -p "$prOut/nix-support"
|
mkdir -p "${!outputDev}/nix-support"
|
||||||
substituteAll "$setupHook" "$prOut/nix-support/setup-hook"
|
substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Propagate user-env packages into the output with binaries, TODO?
|
||||||
|
|
||||||
|
if [ -n "$propagatedUserEnvPkgs" ]; then
|
||||||
|
mkdir -p "${!outputBin}/nix-support"
|
||||||
|
echo "$propagatedUserEnvPkgs" > "${!outputBin}/nix-support/propagated-user-env-packages"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
runHook postFixup
|
runHook postFixup
|
||||||
|
Loading…
x
Reference in New Issue
Block a user