1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

Add testcase for nix develop with __structuredAttrs

This commit is contained in:
Maximilian Bosch 2021-05-18 15:07:30 +02:00
parent f1e281c4fe
commit 3504c811a5
No known key found for this signature in database
GPG key ID: 091DBF4D1FC46B8E
5 changed files with 24 additions and 3 deletions

View file

@ -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)) {

View file

@ -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