[Nix-dev] setup-new and propagatedBuildInputs, sourcing setup-new multiple times ?
Marc Weber
marco-oweber at gmx.de
Tue Nov 4 13:58:56 CET 2008
Am I correct that if multiple dependencies have a store path in
propagatedBuildInputs that /nix-support/setup-hook will be sourced
multiple times?
Do we want this? I mean if you have PYTHONPATH=PATH1:PATH1:PATH1 it will
only make everything slightly slower but I can't see any benefits?
Does someone mind me adding code to prevent this?
Marc
An implementation could look like this:
If you know a better way than using arrays let me know.
#!/bin/sh
contains(){
# $1 var name containing array
# $2 value checked for membership
for i in "${!1}"; do
[ "$i" == "$2" ] && return 0
done
return 1
}
sourceOnce(){
# $1 path to source (may contain spaces)
if contains sourced "$1"; then
echo "$1 already sourced"
else
echo sourcing "$1"
sourced=("${sourced[@]}" "$1")
fi
}
sourceOnce "/foo/ bar"
sourceOnce "/foo/ bar2"
sourceOnce "/foo/ bar"
More information about the nix-dev
mailing list