diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2021-05-18 15:07:30 +0200 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2021-06-22 19:15:57 +0200 |
commit | 3504c811a55ecd58e0712cf24829c67c192f5e80 (patch) | |
tree | 97d291caa783961a4c55e3d39c1fac0097de0f20 /src/nix | |
parent | f1e281c4fe1263a0c848bc8aaf57a0e61a99fa93 (diff) |
Add testcase for `nix develop` with `__structuredAttrs`
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/develop.cc | 3 | ||||
-rw-r--r-- | src/nix/get-env.sh | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/nix/develop.cc b/src/nix/develop.cc index 3443fab73..ee782c4ec 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -256,6 +256,9 @@ struct Common : InstallableCommand, MixProfile // FIXME: properly unquote 'outputs'. StringMap rewrites; for (auto & outputName : tokenizeString<std::vector<std::string>>(replaceStrings(outputs->second.quoted, "'", ""))) { + // Hacky way to obtain the key of an associate array. This is needed for strctured attrs where + // `outputs` is an associative array. If the regex isn't matched, the non-structured-attrs behavior will + // be used. std::regex ptrn(R"re(\[([A-z0-9]+)\]=.*)re"); std::smatch match; if (std::regex_match(outputName, match, ptrn)) { diff --git a/src/nix/get-env.sh b/src/nix/get-env.sh index b6b8310a9..431440516 100644 --- a/src/nix/get-env.sh +++ b/src/nix/get-env.sh @@ -8,6 +8,9 @@ if [[ -n $stdenv ]]; then source $stdenv/setup fi +# 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 @@ -16,10 +19,10 @@ fi for __output in $__olist; do if [[ -z $__done ]]; then - export > ${!__output} - set >> ${!__output} + export > "${!__output}" + set >> "${!__output}" __done=1 else - echo -n >> ${!__output} + echo -n >> "${!__output}" fi done |