mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-18 11:44:07 +00:00
8bc5104a6e
When specifying the `builder` attribute in `stdenv.mkDerivation`, this will be effectively transformed into builtins.derivation { builder = stdenv.shell; args = [ "-e" builder ]; } This also means that `default-builder.sh` is never sourced and as a result it's not guaranteed that `$NIX_ATTRS_SH_FILE` is set to a correct location[1]. Also, we need to source `.attrs.sh` to source `$stdenv`. So, the following is done now: * If `$NIX_ATTRS_SH_FILE` points to a correct location, then use it. Directly using `.attrs.sh` is problematic for `nix-shell(1)` usage (see previous commit for more context), so prefer the environment variable if possible. * Otherwise, if `.attrs.sh` exists, then use it. See [1] for when this can happen. * If neither applies, it can be assumed that `__structuredAttrs` is turned off and thus nothing needs to be done. [1] It's possible that it doesn't exist at all - in case of Nix 2.3 or it can point to a wrong location on older Nix versions with a bug in `__structuredAttrs`.
49 lines
1.3 KiB
Bash
49 lines
1.3 KiB
Bash
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
|
|
source $stdenv/setup
|
|
|
|
# Wrap the given `aclocal' program, appending extra `-I' flags
|
|
# corresponding to the directories listed in $ACLOCAL_PATH. (Note
|
|
# that `wrapProgram' can't be used for that purpose since it can only
|
|
# prepend flags, not append them.)
|
|
wrapAclocal() {
|
|
local program="$1"
|
|
local wrapped="$(dirname $program)/.$(basename $program)-wrapped"
|
|
|
|
mv "$program" "$wrapped"
|
|
cat > "$program"<<EOF
|
|
#! $SHELL -e
|
|
|
|
unset extraFlagsArray
|
|
declare -a extraFlagsArray
|
|
|
|
oldIFS=\$IFS
|
|
IFS=:
|
|
for dir in \$ACLOCAL_PATH; do
|
|
if test -n "\$dir" -a -d "\$dir"; then
|
|
extraFlagsArray=("\${extraFlagsArray[@]}" "-I" "\$dir")
|
|
fi
|
|
done
|
|
IFS=\$oldIFS
|
|
|
|
exec "$wrapped" "\$@" "\${extraFlagsArray[@]}"
|
|
EOF
|
|
chmod +x "$program"
|
|
}
|
|
|
|
postInstall() {
|
|
# Create a wrapper around `aclocal' that converts every element in
|
|
# `ACLOCAL_PATH' into a `-I dir' option. This way `aclocal'
|
|
# becomes modular; M4 macros do not need to be stored in a single
|
|
# global directory, while callers of `aclocal' do not need to pass
|
|
# `-I' options explicitly.
|
|
|
|
for prog in $out/bin/aclocal*; do
|
|
wrapAclocal "$prog"
|
|
done
|
|
|
|
ln -s aclocal-1.11 $out/share/aclocal
|
|
ln -s automake-1.11 $out/share/automake
|
|
}
|
|
|
|
genericBuild
|