aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/binary-cache-store.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/binary-cache-store.hh')
-rw-r--r--src/libstore/binary-cache-store.hh52
1 files changed, 33 insertions, 19 deletions
diff --git a/src/libstore/binary-cache-store.hh b/src/libstore/binary-cache-store.hh
index 52ef8aa7a..657be2fcf 100644
--- a/src/libstore/binary-cache-store.hh
+++ b/src/libstore/binary-cache-store.hh
@@ -11,17 +11,21 @@ namespace nix {
struct NarInfo;
-class BinaryCacheStore : public Store
+struct BinaryCacheStoreConfig : virtual StoreConfig
{
-public:
-
- const Setting<std::string> compression{this, "xz", "compression", "NAR compression method ('xz', 'bzip2', or 'none')"};
- const Setting<bool> writeNARListing{this, false, "write-nar-listing", "whether to write a JSON file listing the files in each NAR"};
- const Setting<bool> writeDebugInfo{this, false, "index-debug-info", "whether to index DWARF debug info files by build ID"};
- const Setting<Path> secretKeyFile{this, "", "secret-key", "path to secret key used to sign the binary cache"};
- const Setting<Path> localNarCache{this, "", "local-nar-cache", "path to a local cache of NARs"};
- const Setting<bool> parallelCompression{this, false, "parallel-compression",
+ using StoreConfig::StoreConfig;
+
+ const Setting<std::string> compression{(StoreConfig*) this, "xz", "compression", "NAR compression method ('xz', 'bzip2', or 'none')"};
+ const Setting<bool> writeNARListing{(StoreConfig*) this, false, "write-nar-listing", "whether to write a JSON file listing the files in each NAR"};
+ const Setting<bool> writeDebugInfo{(StoreConfig*) this, false, "index-debug-info", "whether to index DWARF debug info files by build ID"};
+ const Setting<Path> secretKeyFile{(StoreConfig*) this, "", "secret-key", "path to secret key used to sign the binary cache"};
+ const Setting<Path> localNarCache{(StoreConfig*) this, "", "local-nar-cache", "path to a local cache of NARs"};
+ const Setting<bool> parallelCompression{(StoreConfig*) this, false, "parallel-compression",
"enable multi-threading compression, available for xz only currently"};
+};
+
+class BinaryCacheStore : public virtual BinaryCacheStoreConfig, public virtual Store
+{
private:
@@ -29,6 +33,9 @@ private:
protected:
+ // The prefix under which realisation infos will be stored
+ const std::string realisationsPrefix = "realisations";
+
BinaryCacheStore(const Params & params);
public:
@@ -36,9 +43,13 @@ public:
virtual bool fileExists(const std::string & path) = 0;
virtual void upsertFile(const std::string & path,
- const std::string & data,
+ std::shared_ptr<std::basic_iostream<char>> istream,
const std::string & mimeType) = 0;
+ void upsertFile(const std::string & path,
+ std::string && data,
+ const std::string & mimeType);
+
/* Note: subclasses must implement at least one of the two
following getFile() methods. */
@@ -54,7 +65,7 @@ public:
public:
- virtual void init();
+ virtual void init() override;
private:
@@ -64,6 +75,10 @@ private:
void writeNarInfo(ref<NarInfo> narInfo);
+ ref<const ValidPathInfo> addToStoreCommon(
+ Source & narSource, RepairFlag repair, CheckSigsFlag checkSigs,
+ std::function<ValidPathInfo(HashResult)> mkInfo);
+
public:
bool isValidPathUncached(const StorePath & path) override;
@@ -75,8 +90,10 @@ public:
{ unsupported("queryPathFromHashPart"); }
void addToStore(const ValidPathInfo & info, Source & narSource,
- RepairFlag repair, CheckSigsFlag checkSigs,
- std::shared_ptr<FSAccessor> accessor) override;
+ RepairFlag repair, CheckSigsFlag checkSigs) override;
+
+ StorePath addToStoreFromDump(Source & dump, const string & name,
+ FileIngestionMethod method, HashType hashAlgo, RepairFlag repair) override;
StorePath addToStore(const string & name, const Path & srcPath,
FileIngestionMethod method, HashType hashAlgo,
@@ -85,14 +102,11 @@ public:
StorePath addTextToStore(const string & name, const string & s,
const StorePathSet & references, RepairFlag repair) override;
- void narFromPath(const StorePath & path, Sink & sink) override;
+ void registerDrvOutput(const Realisation & info) override;
- BuildResult buildDerivation(const StorePath & drvPath, const BasicDerivation & drv,
- BuildMode buildMode) override
- { unsupported("buildDerivation"); }
+ std::optional<const Realisation> queryRealisation(const DrvOutput &) override;
- void ensurePath(const StorePath & path) override
- { unsupported("ensurePath"); }
+ void narFromPath(const StorePath & path, Sink & sink) override;
ref<FSAccessor> getFSAccessor() override;