diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index 49b349550..e59fc62ad 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -1009,11 +1009,13 @@ std::vector> SourceExprCommand::parseInstallables( } try { - bool isAttrPath = std::regex_match(s, attrPathRegex); - - auto actualRef = isAttrPath ? "flake:default#" + s : s; + auto prefixS = std::string { prefix }; - auto [flakeRef, fragment] = parseFlakeRefWithFragment(std::string { prefix }, absPath(".")); + bool isAttrPath = std::regex_match(prefixS, attrPathRegex); + + auto actualRef = isAttrPath ? "flake:default#" + prefixS : prefixS; + + auto [flakeRef, fragment] = parseFlakeRefWithFragment(actualRef, absPath(".")); auto state = getEvalState();