From 6477d7c2ca3ff84f9d1b502d4d62bddfe3b77b0f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 12 Jun 2025 16:11:54 +0200 Subject: [PATCH] mountInput(): Optimize getting the NAR hash for real store paths --- src/libexpr/paths.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libexpr/paths.cc b/src/libexpr/paths.cc index d85f00470..bdf817e3b 100644 --- a/src/libexpr/paths.cc +++ b/src/libexpr/paths.cc @@ -81,9 +81,13 @@ StorePath EvalState::mountInput( auto getNarHash = [&]() { - if (!_narHash) - // FIXME: use fetchToStore to make it cache this - _narHash = accessor->hashPath(CanonPath::root); + if (!_narHash) { + if (store->isValidPath(storePath)) + _narHash = store->queryPathInfo(storePath)->narHash; + else + // FIXME: use fetchToStore to make it cache this + _narHash = accessor->hashPath(CanonPath::root); + } return _narHash; };