nix-build: Fix !<output> handling

This was broken by 22a754c091.

https://hydra.nixos.org/eval/1573669
This commit is contained in:
Eelco Dolstra 2020-03-04 13:55:15 +01:00
parent 887030f211
commit d37dc71e3c
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
3 changed files with 4 additions and 3 deletions

View file

@ -64,7 +64,7 @@ std::optional<StorePath> Store::maybeParseStorePath(std::string_view path) const
} }
} }
bool Store::isStorePath(const Path & path) const bool Store::isStorePath(std::string_view path) const
{ {
return (bool) maybeParseStorePath(path); return (bool) maybeParseStorePath(path);
} }

View file

@ -305,7 +305,7 @@ public:
/* Return true if path is a store path, i.e. a direct child of /* Return true if path is a store path, i.e. a direct child of
the Nix store. */ the Nix store. */
bool isStorePath(const Path & path) const; bool isStorePath(std::string_view path) const;
/* Chop off the parts after the top-level store name, e.g., /* Chop off the parts after the top-level store name, e.g.,
/nix/store/abcd-foo/bar => /nix/store/abcd-foo. */ /nix/store/abcd-foo/bar => /nix/store/abcd-foo. */

View file

@ -295,7 +295,8 @@ static void _main(int argc, char * * argv)
try { try {
absolute = canonPath(absPath(i), true); absolute = canonPath(absPath(i), true);
} catch (Error & e) {}; } catch (Error & e) {};
if (store->isStorePath(absolute) && std::regex_match(absolute, std::regex(".*\\.drv(!.*)?"))) auto [path, outputNames] = parsePathWithOutputs(absolute);
if (store->isStorePath(path) && hasSuffix(path, ".drv"))
drvs.push_back(DrvInfo(*state, store, absolute)); drvs.push_back(DrvInfo(*state, store, absolute));
else else
/* If we're in a #! script, interpret filenames /* If we're in a #! script, interpret filenames