From 4173743a3c1f0418c298d12cc71ffa26f6bc848d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 9 May 2023 17:20:58 -0400 Subject: [PATCH] Implement more queries --- src/libstore/local-overlay-store.cc | 16 ++++++++++++++++ src/libstore/local-overlay-store.hh | 4 ++++ tests/overlay-local-store/inner.sh | 15 +++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/libstore/local-overlay-store.cc b/src/libstore/local-overlay-store.cc index 431b82c90..c6b721b48 100644 --- a/src/libstore/local-overlay-store.cc +++ b/src/libstore/local-overlay-store.cc @@ -103,6 +103,22 @@ bool LocalOverlayStore::isValidPathUncached(const StorePath & path) } +void LocalOverlayStore::queryReferrers(const StorePath & path, StorePathSet & referrers) +{ + LocalStore::queryReferrers(path, referrers); + lowerStore->queryReferrers(path, referrers); +} + + +StorePathSet LocalOverlayStore::queryValidDerivers(const StorePath & path) +{ + auto res = LocalStore::queryValidDerivers(path); + for (auto p : lowerStore->queryValidDerivers(path)) + res.insert(p); + return res; +} + + std::optional LocalOverlayStore::queryPathFromHashPart(const std::string & hashPart) { auto res = LocalStore::queryPathFromHashPart(hashPart); diff --git a/src/libstore/local-overlay-store.hh b/src/libstore/local-overlay-store.hh index 88da4ba4a..9bc513b3e 100644 --- a/src/libstore/local-overlay-store.hh +++ b/src/libstore/local-overlay-store.hh @@ -89,6 +89,10 @@ private: bool isValidPathUncached(const StorePath & path) override; + void queryReferrers(const StorePath & path, StorePathSet & referrers) override; + + StorePathSet queryValidDerivers(const StorePath & path) override; + std::optional queryPathFromHashPart(const std::string & hashPart) override; void registerValidPaths(const ValidPathInfos & infos) override; diff --git a/tests/overlay-local-store/inner.sh b/tests/overlay-local-store/inner.sh index d13d8b9ab..7ab587b87 100755 --- a/tests/overlay-local-store/inner.sh +++ b/tests/overlay-local-store/inner.sh @@ -55,6 +55,21 @@ expect 1 stat $(toRealPath "$storeBTop" "$path") # Checking for path in overlay store matching lower layer diff $(toRealPath "$storeA/nix/store" "$path") $(toRealPath "$TEST_ROOT/merged-store/nix/store" "$path") +# Checking requisites query agreement +[[ \ + $(nix-store --store $storeA --query --requisites $drvPath) \ + == \ + $(nix-store --store $storeB --query --requisites $drvPath) \ + ]] + +# Checking referrers query agreement +busyboxStore=$(nix store --store $storeA add-path $busybox) +[[ \ + $(nix-store --store $storeA --query --referrers $busyboxStore) \ + == \ + $(nix-store --store $storeB --query --referrers $busyboxStore) \ + ]] + # Checking derivers query agreement [[ \ $(nix-store --store $storeA --query --deriver $path) \