aboutsummaryrefslogtreecommitdiff
path: root/src/nix/get-env.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/get-env.sh')
-rw-r--r--src/nix/get-env.sh14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/nix/get-env.sh b/src/nix/get-env.sh
index 2df3e543f..42c806450 100644
--- a/src/nix/get-env.sh
+++ b/src/nix/get-env.sh
@@ -111,12 +111,20 @@ __escapeString() {
printf '"%s"' "$__s"
}
-# Dump the bash environment as JSON.
-for __output in $outputs; do
+# In case of `__structuredAttrs = true;` the list of outputs is an associative
+# array with a format like `outname => /nix/store/hash-drvname-outname`, so `__olist`
+# must contain the array's keys (hence `${!...[@]}`) in this case.
+if [ -e .attrs.sh ]; then
+ __olist="${!outputs[@]}"
+else
+ __olist=$outputs
+fi
+
+for __output in $__olist; do
if [[ -z $__done ]]; then
__dumpEnv > ${!__output}
__done=1
else
- echo -n >> ${!__output}
+ echo -n >> "${!__output}"
fi
done