mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-16 17:14:00 +00:00
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`.
This commit is contained in:
parent
53c5f08415
commit
8bc5104a6e
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
doSub() {
|
doSub() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
set -e
|
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
|
source $stdenv/setup
|
||||||
|
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
echo "unpacking $src..."
|
echo "unpacking $src..."
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 "$stdenv/setup"
|
||||||
|
|
||||||
echo "exporting \`$url' (revision $rev) into \`$out'"
|
echo "exporting \`$url' (revision $rev) into \`$out'"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
(echo "#!$SHELL"; \
|
(echo "#!$SHELL"; \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
tagtext=""
|
tagtext=""
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 "${stdenv}/setup"
|
||||||
echo "exporting ${repository}/${imageName} (tag: ${tag}) into ${out}"
|
echo "exporting ${repository}/${imageName} (tag: ${tag}) into ${out}"
|
||||||
mkdir -p "${out}"
|
mkdir -p "${out}"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
echo "Cloning Fossil $url [$rev] into $out"
|
echo "Cloning Fossil $url [$rev] into $out"
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# - revision specified and remote has a HEAD
|
# - revision specified and remote has a HEAD
|
||||||
# - revision specified and remote without 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
|
source $stdenv/setup
|
||||||
|
|
||||||
echo "exporting $url (rev $rev) into $out"
|
echo "exporting $url (rev $rev) into $out"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
echo "getting $url${rev:+ ($rev)} into $out"
|
echo "getting $url${rev:+ ($rev)} into $out"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
# Curl flags to handle redirects, not use EPSV, handle cookies for
|
# Curl flags to handle redirects, not use EPSV, handle cookies for
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
echo "exporting $url (r$rev) into $out"
|
echo "exporting $url (r$rev) into $out"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
echo "exporting $url (r$rev) into $out"
|
echo "exporting $url (r$rev) into $out"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
source $mirrorsFile
|
source $mirrorsFile
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
providedPreConfigure="$preConfigure";
|
providedPreConfigure="$preConfigure";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
export JAVA_HOME=$jre
|
export JAVA_HOME=$jre
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
echo "exporting egg ${eggName} (version $version) into $out"
|
echo "exporting egg ${eggName} (version $version) into $out"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
pkgdir=$(pwd)/pkg
|
pkgdir=$(pwd)/pkg
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
tar xf $src
|
tar xf $src
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# -*- shell-script -*-
|
# -*- 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
|
source $stdenv/setup
|
||||||
|
|
||||||
function extract
|
function extract
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
configureFlags="-prefix $out $configureFlags"
|
configureFlags="-prefix $out $configureFlags"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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.
|
# Glibc cannot have itself in its RPATH.
|
||||||
export NIX_NO_SELF_RPATH=1
|
export NIX_NO_SELF_RPATH=1
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
genericBuild
|
genericBuild
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
mkdir unzipped
|
mkdir unzipped
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
PERL5LIB="$PERL5LIB${PERL5LIB:+:}$out/lib/perl5/site_perl"
|
PERL5LIB="$PERL5LIB${PERL5LIB:+:}$out/lib/perl5/site_perl"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
boot_bin=$out/bin/boot
|
boot_bin=$out/bin/boot
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
# Wrap the given `aclocal' program, appending extra `-I' flags
|
# Wrap the given `aclocal' program, appending extra `-I' flags
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
tar zxvf $src
|
tar zxvf $src
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
arch=$(uname -m)
|
arch=$(uname -m)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
unpackManually() {
|
unpackManually() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
mkdir -p $out/lib
|
mkdir -p $out/lib
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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 $stdenv/setup
|
||||||
|
|
||||||
unzip $src
|
unzip $src
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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.
|
# This is the builder for all X.org components.
|
||||||
source $stdenv/setup
|
source $stdenv/setup
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
if [ -f .attrs.sh ]; then
|
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
|
||||||
. .attrs.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
source $stdenv/setup
|
source $stdenv/setup
|
||||||
genericBuild
|
genericBuild
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
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
|
set -x
|
||||||
|
|
||||||
export NIX_DEBUG=1
|
export NIX_DEBUG=1
|
||||||
|
Loading…
Reference in New Issue
Block a user