treewide: refactor `.attrs.sh` detection

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`.

Changed files
+36 -38
nixos
modules
services
networking
ircd-hybrid
web-servers
jboss
pkgs
applications
misc
adobe-reader
build-support
fetchbzr
fetchcvs
fetchdarcs
fetchdocker
fetchfossil
fetchgit
fetchhg
fetchipfs
fetchmtn
fetchsvn
fetchsvnssh
fetchurl
desktops
gnustep
make
development
compilers
aspectj
chicken
4
fetchegg
fpc
ios-cross-compile
ocaml
libraries
perl-modules
generic
tools
build-managers
boot
misc
automake
parsing
antlr
misc
cups
drivers
samsung
4.00.39
os-specific
linux
nvidia-x11
opengl
xorg-sys
servers
http
tomcat
axis2
x11
xorg
stdenv
test
simple
+1 -1
nixos/modules/services/networking/ircd-hybrid/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
doSub() {
+1 -1
nixos/modules/services/web-servers/jboss/builder.sh
···
set -e
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
mkdir -p $out/bin
+1 -1
pkgs/applications/misc/adobe-reader/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
echo "unpacking $src..."
+1 -1
pkgs/build-support/fetchbzr/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source "$stdenv/setup"
echo "exporting \`$url' (revision $rev) into \`$out'"
+1 -1
pkgs/build-support/fetchcvs/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
(echo "#!$SHELL"; \
+1 -1
pkgs/build-support/fetchdarcs/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
tagtext=""
+1 -1
pkgs/build-support/fetchdocker/fetchdocker-builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source "${stdenv}/setup"
echo "exporting ${repository}/${imageName} (tag: ${tag}) into ${out}"
mkdir -p "${out}"
+1 -1
pkgs/build-support/fetchfossil/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
echo "Cloning Fossil $url [$rev] into $out"
+1 -1
pkgs/build-support/fetchgit/builder.sh
···
# - revision specified and remote has a HEAD
# - revision specified and remote without HEAD
#
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
echo "exporting $url (rev $rev) into $out"
+1 -1
pkgs/build-support/fetchhg/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
echo "getting $url${rev:+ ($rev)} into $out"
+1 -1
pkgs/build-support/fetchipfs/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
# Curl flags to handle redirects, not use EPSV, handle cookies for
+1 -1
pkgs/build-support/fetchmtn/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
set -x
+1 -1
pkgs/build-support/fetchsvn/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
echo "exporting $url (r$rev) into $out"
+1 -1
pkgs/build-support/fetchsvnssh/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
echo "exporting $url (r$rev) into $out"
+1 -1
pkgs/build-support/fetchurl/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
source $mirrorsFile
+1 -1
pkgs/desktops/gnustep/make/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
providedPreConfigure="$preConfigure";
+1 -1
pkgs/development/compilers/aspectj/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
export JAVA_HOME=$jre
+1 -1
pkgs/development/compilers/chicken/4/fetchegg/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
echo "exporting egg ${eggName} (version $version) into $out"
+1 -1
pkgs/development/compilers/fpc/binary-builder-darwin.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
pkgdir=$(pwd)/pkg
+1 -1
pkgs/development/compilers/fpc/binary-builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
tar xf $src
+1 -1
pkgs/development/compilers/ios-cross-compile/9.2_builder.sh
···
# -*- shell-script -*-
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
function extract
+1 -1
pkgs/development/compilers/ocaml/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
configureFlags="-prefix $out $configureFlags"
+1 -1
pkgs/development/libraries/glibc/locales-builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
# Glibc cannot have itself in its RPATH.
export NIX_NO_SELF_RPATH=1
+1 -1
pkgs/development/libraries/gtk-sharp/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
genericBuild
+1 -1
pkgs/development/libraries/wtk/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
mkdir unzipped
+1 -1
pkgs/development/perl-modules/generic/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
PERL5LIB="$PERL5LIB${PERL5LIB:+:}$out/lib/perl5/site_perl"
+1 -1
pkgs/development/tools/build-managers/boot/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
boot_bin=$out/bin/boot
+1 -1
pkgs/development/tools/misc/automake/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
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
+1 -1
pkgs/development/tools/parsing/antlr/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
tar zxvf $src
+1 -1
pkgs/misc/cups/drivers/samsung/4.00.39/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
arch=$(uname -m)
+1 -1
pkgs/os-specific/linux/nvidia-x11/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
unpackManually() {
+1 -1
pkgs/os-specific/linux/opengl/xorg-sys/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
mkdir -p $out/lib
+1 -1
pkgs/servers/http/tomcat/axis2/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
unzip $src
+1 -1
pkgs/servers/x11/xorg/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
# This is the builder for all X.org components.
source $stdenv/setup
+1 -3
pkgs/stdenv/generic/default-builder.sh
···
-
if [ -f .attrs.sh ]; then
-
. .attrs.sh
-
fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
genericBuild
+1 -1
pkgs/test/simple/builder.sh
···
-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
+
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
set -x
export NIX_DEBUG=1