summaryrefslogtreecommitdiffstats
path: root/pkgs/test/simple
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2023-09-28 15:09:26 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2023-10-04 18:36:57 +0200
commit8bc5104a6e6a6acf09f9d7ddf1c6a9293efb405a (patch)
treeb8bbd5c3f83db73c1db49249e11a1110462b6433 /pkgs/test/simple
parent53c5f084151264701e6332f1606bb892bf9c3574 (diff)
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`.
Diffstat (limited to 'pkgs/test/simple')
-rw-r--r--pkgs/test/simple/builder.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkgs/test/simple/builder.sh b/pkgs/test/simple/builder.sh
index 908faec3c388..0b09a109bead 100644
--- a/pkgs/test/simple/builder.sh
+++ b/pkgs/test/simple/builder.sh
@@ -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
export NIX_DEBUG=1