From 447928bdb55d160617387e7ac5954f9a8f36004b Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 13 May 2021 01:20:49 +0200 Subject: [PATCH] Fix usage of structured attrs for `nix develop` --- src/nix/develop.cc | 5 +++++ src/nix/get-env.sh | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/nix/develop.cc b/src/nix/develop.cc index e51de2de8..3443fab73 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -256,6 +256,11 @@ struct Common : InstallableCommand, MixProfile // FIXME: properly unquote 'outputs'. StringMap rewrites; for (auto & outputName : tokenizeString>(replaceStrings(outputs->second.quoted, "'", ""))) { + std::regex ptrn(R"re(\[([A-z0-9]+)\]=.*)re"); + std::smatch match; + if (std::regex_match(outputName, match, ptrn)) { + outputName = match[1]; + } auto from = buildEnvironment.env.find(outputName); assert(from != buildEnvironment.env.end()); // FIXME: unquote diff --git a/src/nix/get-env.sh b/src/nix/get-env.sh index 091c0f573..b6b8310a9 100644 --- a/src/nix/get-env.sh +++ b/src/nix/get-env.sh @@ -8,7 +8,13 @@ if [[ -n $stdenv ]]; then source $stdenv/setup fi -for __output in $outputs; do +if [ -e .attrs.sh ]; then + __olist="${!outputs[@]}" +else + __olist=$outputs +fi + +for __output in $__olist; do if [[ -z $__done ]]; then export > ${!__output} set >> ${!__output}