mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-04-29 02:01:34 +00:00
stdenv-setup: Make the package accumulators associative arrays instead of strings
This is generally cleaner: less eval, less worrying about separators, and probably also faster. I got the idea from that python wrapper script.
This commit is contained in:
parent
3cb745d5a6
commit
8d76effc17
pkgs
development
servers/x11/xorg
stdenv/generic
@ -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
|
||||||
|
@ -86,7 +86,7 @@ wrapPythonProgramsIn() {
|
|||||||
_addToPythonPath() {
|
_addToPythonPath() {
|
||||||
local dir="$1"
|
local dir="$1"
|
||||||
# Stop if we've already visited here.
|
# Stop if we've already visited here.
|
||||||
if [ -n "${pythonPathsSeen[$dir]}" ]; then return; fi
|
[ -n "${pythonPathsSeen[$dir]}" ] || return 0
|
||||||
pythonPathsSeen[$dir]=1
|
pythonPathsSeen[$dir]=1
|
||||||
# addToSearchPath is defined in stdenv/generic/setup.sh. It will have
|
# addToSearchPath is defined in stdenv/generic/setup.sh. It will have
|
||||||
# the effect of calling `export program_X=$dir/...:$program_X`.
|
# the effect of calling `export program_X=$dir/...:$program_X`.
|
||||||
|
@ -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"
|
||||||
|
@ -275,17 +275,14 @@ runHook addInputsHook
|
|||||||
|
|
||||||
# Recursively find all build inputs.
|
# Recursively find all build inputs.
|
||||||
findInputs() {
|
findInputs() {
|
||||||
local pkg="$1"
|
local pkg=$1
|
||||||
local var=$2
|
local var=$2
|
||||||
|
local -n varDeref=$var
|
||||||
local propagatedBuildInputsFile=$3
|
local propagatedBuildInputsFile=$3
|
||||||
|
|
||||||
case ${!var} in
|
# Stop if we've already added this one
|
||||||
*\ $pkg\ *)
|
[[ -z "${varDeref["$pkg"]}" ]] || return 0
|
||||||
return 0
|
varDeref["$pkg"]=1
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
eval $var="'${!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
|
||||||
@ -296,8 +293,8 @@ findInputs() {
|
|||||||
source "$pkg"
|
source "$pkg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $1/bin ]; then
|
if [ -d "$pkg/bin" ]; then
|
||||||
addToSearchPath _PATH $1/bin
|
addToSearchPath _PATH "$pkg/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$pkg/nix-support/setup-hook" ]; then
|
if [ -f "$pkg/nix-support/setup-hook" ]; then
|
||||||
@ -317,19 +314,19 @@ findInputs() {
|
|||||||
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
|
||||||
nativePkgs=""
|
declare -gA 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
|
||||||
crossPkgs=""
|
declare -gA 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
|
||||||
|
|
||||||
nativePkgs=""
|
declare -gA 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
|
||||||
@ -345,7 +342,7 @@ _addToNativeEnv() {
|
|||||||
runHook envHook "$pkg"
|
runHook envHook "$pkg"
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in $nativePkgs; do
|
for i in "${!nativePkgs[@]}"; do
|
||||||
_addToNativeEnv $i
|
_addToNativeEnv $i
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -356,7 +353,7 @@ _addToCrossEnv() {
|
|||||||
runHook crossEnvHook "$pkg"
|
runHook crossEnvHook "$pkg"
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in $crossPkgs; do
|
for i in "${!crossPkgs[@]}"; do
|
||||||
_addToCrossEnv $i
|
_addToCrossEnv $i
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user