diff --git a/src/libstore/path.cc b/src/libstore/path.cc index 70b919adc..9a28aa96a 100644 --- a/src/libstore/path.cc +++ b/src/libstore/path.cc @@ -64,7 +64,7 @@ std::optional 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); } diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index a1cfb314a..a000757fb 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -305,7 +305,7 @@ public: /* Return true if ‘path’ is a store path, i.e. a direct child of 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., /nix/store/abcd-foo/bar => /nix/store/abcd-foo. */ diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index ff95ad787..27ec7d0fe 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -295,7 +295,8 @@ static void _main(int argc, char * * argv) try { absolute = canonPath(absPath(i), true); } 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)); else /* If we're in a #! script, interpret filenames