aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-05-13 01:20:49 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2021-06-22 19:15:57 +0200
commit447928bdb55d160617387e7ac5954f9a8f36004b (patch)
tree762c55292b24cd0f64aa2272839355f81906d422 /src/nix
parent3944a120ec6986c723bf36bfade9b331dd4af68a (diff)
Fix usage of structured attrs for `nix develop`
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/develop.cc5
-rw-r--r--src/nix/get-env.sh8
2 files changed, 12 insertions, 1 deletions
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<std::vector<std::string>>(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}