Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
nix::BinaryCacheStore Class Referenceabstract

#include <binary-cache-store.hh>

Inheritance diagram for nix::BinaryCacheStore:
nix::BinaryCacheStoreConfig nix::Store nix::LogStore nix::StoreConfig nix::StoreConfig nix::Store nix::StoreDirConfig nix::StoreDirConfig nix::StoreConfig nix::Config nix::Config nix::StoreDirConfig nix::AbstractConfig nix::AbstractConfig nix::Config nix::AbstractConfig nix::HttpBinaryCacheStore nix::LocalBinaryCacheStore nix::S3BinaryCacheStore

Public Member Functions

virtual bool fileExists (const std::string &path)=0
 
virtual void upsertFile (const std::string &path, 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)
 
virtual void getFile (const std::string &path, Sink &sink)
 
virtual std::optional< std::string > getNixCacheInfo ()
 
virtual void getFile (const std::string &path, Callback< std::optional< std::string > > callback) noexcept
 
std::optional< std::string > getFile (const std::string &path)
 
virtual void init () override
 
bool isValidPathUncached (const StorePath &path) override
 
void queryPathInfoUncached (const StorePath &path, Callback< std::shared_ptr< const ValidPathInfo > > callback) noexcept override
 
std::optional< StorePathqueryPathFromHashPart (const std::string &hashPart) override
 
void addToStore (const ValidPathInfo &info, Source &narSource, RepairFlag repair, CheckSigsFlag checkSigs) override
 
StorePath addToStoreFromDump (Source &dump, std::string_view name, FileSerialisationMethod dumpMethod, ContentAddressMethod hashMethod, HashAlgorithm hashAlgo, const StorePathSet &references, RepairFlag repair) override
 
StorePath addToStore (std::string_view name, const SourcePath &path, ContentAddressMethod method, HashAlgorithm hashAlgo, const StorePathSet &references, PathFilter &filter, RepairFlag repair) override
 
void registerDrvOutput (const Realisation &info) override
 
void queryRealisationUncached (const DrvOutput &, Callback< std::shared_ptr< const Realisation > > callback) noexcept override
 
void narFromPath (const StorePath &path, Sink &sink) override
 
ref< SourceAccessorgetFSAccessor (bool requireValidPath=true) override
 
void addSignatures (const StorePath &storePath, const StringSet &sigs) override
 
std::optional< std::string > getBuildLogExact (const StorePath &path) override
 
void addBuildLog (const StorePath &drvPath, std::string_view log) override
 
- Public Member Functions inherited from nix::BinaryCacheStoreConfig
 StoreConfig ()=delete
 
- Public Member Functions inherited from nix::StoreConfig
virtual const std::string name ()=0
 
virtual std::string doc ()
 
virtual std::optional< ExperimentalFeatureexperimentalFeature () const
 
 StoreDirConfig ()=delete
 
- Public Member Functions inherited from nix::StoreDirConfig
StorePath parseStorePath (std::string_view path) const
 
std::optional< StorePathmaybeParseStorePath (std::string_view path) const
 
std::string printStorePath (const StorePath &path) const
 
StorePathSet parseStorePathSet (const PathSet &paths) const
 
PathSet printStorePathSet (const StorePathSet &path) const
 
std::string showPaths (const StorePathSet &paths)
 
bool isInStore (PathView path) const
 
bool isStorePath (std::string_view path) const
 
std::pair< StorePath, PathtoStorePath (PathView path) const
 
StorePath makeStorePath (std::string_view type, std::string_view hash, std::string_view name) const
 
StorePath makeStorePath (std::string_view type, const Hash &hash, std::string_view name) const
 
StorePath makeOutputPath (std::string_view id, const Hash &hash, std::string_view name) const
 
StorePath makeFixedOutputPath (std::string_view name, const FixedOutputInfo &info) const
 
StorePath makeFixedOutputPathFromCA (std::string_view name, const ContentAddressWithReferences &ca) const
 
std::pair< StorePath, HashcomputeStorePath (std::string_view name, const SourcePath &path, ContentAddressMethod method=FileIngestionMethod::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references={}, PathFilter &filter=defaultPathFilter) const
 
 Config (StringMap initials={})
 
- Public Member Functions inherited from nix::Config
 Config (StringMap initials={})
 
bool set (const std::string &name, const std::string &value) override
 
void addSetting (AbstractSetting *setting)
 
void getSettings (std::map< std::string, SettingInfo > &res, bool overriddenOnly=false) override
 
void resetOverridden () override
 
nlohmann::json toJSON () override
 
std::string toKeyValue () override
 
void convertToArgs (Args &args, const std::string &category) override
 
- Public Member Functions inherited from nix::AbstractConfig
void applyConfig (const std::string &contents, const std::string &path="<unknown>")
 
void warnUnknownSettings ()
 
void reapplyUnknownSettings ()
 
- Public Member Functions inherited from nix::Store
virtual std::string getUri ()=0
 
Path followLinksToStore (std::string_view path) const
 
StorePath followLinksToStorePath (std::string_view path) const
 
bool isValidPath (const StorePath &path)
 
void substitutePaths (const StorePathSet &paths)
 
virtual StorePathSet queryValidPaths (const StorePathSet &paths, SubstituteFlag maybeSubstitute=NoSubstitute)
 
virtual StorePathSet queryAllValidPaths ()
 
ref< const ValidPathInfoqueryPathInfo (const StorePath &path)
 
void queryPathInfo (const StorePath &path, Callback< ref< const ValidPathInfo > > callback) noexcept
 
std::optional< std::shared_ptr< const ValidPathInfo > > queryPathInfoFromClientCache (const StorePath &path)
 
std::shared_ptr< const RealisationqueryRealisation (const DrvOutput &)
 
void queryRealisation (const DrvOutput &, Callback< std::shared_ptr< const Realisation > > callback) noexcept
 
virtual bool pathInfoIsUntrusted (const ValidPathInfo &)
 
virtual bool realisationIsUntrusted (const Realisation &)
 
virtual void queryReferrers (const StorePath &path, StorePathSet &referrers)
 
virtual StorePathSet queryValidDerivers (const StorePath &path)
 
virtual StorePathSet queryDerivationOutputs (const StorePath &path)
 
virtual std::map< std::string, std::optional< StorePath > > queryPartialDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
 
virtual std::map< std::string, std::optional< StorePath > > queryStaticPartialDerivationOutputMap (const StorePath &path)
 
OutputPathMap queryDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
 
virtual StorePathSet querySubstitutablePaths (const StorePathSet &paths)
 
virtual void querySubstitutablePathInfos (const StorePathCAMap &paths, SubstitutablePathInfos &infos)
 
virtual void addMultipleToStore (Source &source, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs)
 
virtual void addMultipleToStore (PathsSource &&pathsToCopy, Activity &act, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs)
 
ValidPathInfo addToStoreSlow (std::string_view name, const SourcePath &path, ContentAddressMethod method=ContentAddressMethod::Raw::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references=StorePathSet(), std::optional< Hash > expectedCAHash={})
 
virtual void registerDrvOutput (const Realisation &output, CheckSigsFlag checkSigs)
 
virtual void buildPaths (const std::vector< DerivedPath > &paths, BuildMode buildMode=bmNormal, std::shared_ptr< Store > evalStore=nullptr)
 
virtual std::vector< KeyedBuildResultbuildPathsWithResults (const std::vector< DerivedPath > &paths, BuildMode buildMode=bmNormal, std::shared_ptr< Store > evalStore=nullptr)
 
virtual BuildResult buildDerivation (const StorePath &drvPath, const BasicDerivation &drv, BuildMode buildMode=bmNormal)
 
virtual void ensurePath (const StorePath &path)
 
virtual void addTempRoot (const StorePath &path)
 
std::string makeValidityRegistration (const StorePathSet &paths, bool showDerivers, bool showHash)
 
virtual void optimiseStore ()
 
virtual bool verifyStore (bool checkContents, RepairFlag repair=NoRepair)
 
virtual void repairPath (const StorePath &path)
 
Derivation derivationFromPath (const StorePath &drvPath)
 
Derivation readDerivation (const StorePath &drvPath)
 
Derivation readInvalidDerivation (const StorePath &drvPath)
 
virtual void computeFSClosure (const StorePathSet &paths, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false)
 
void computeFSClosure (const StorePath &path, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false)
 
virtual void queryMissing (const std::vector< DerivedPath > &targets, StorePathSet &willBuild, StorePathSet &willSubstitute, StorePathSet &unknown, uint64_t &downloadSize, uint64_t &narSize)
 
StorePaths topoSortPaths (const StorePathSet &paths)
 
void exportPaths (const StorePathSet &paths, Sink &sink)
 
void exportPath (const StorePath &path, Sink &sink)
 
StorePaths importPaths (Source &source, CheckSigsFlag checkSigs=CheckSigs)
 
const StatsgetStats ()
 
StorePathSet exportReferences (const StorePathSet &storePaths, const StorePathSet &inputPaths)
 
std::optional< StorePathgetBuildDerivationPath (const StorePath &)
 
void clearPathInfoCache ()
 
virtual void connect ()
 
virtual unsigned int getProtocol ()
 
virtual std::optional< TrustedFlag > isTrustedClient ()=0
 
virtual Path toRealPath (const Path &storePath)
 
Path toRealPath (const StorePath &storePath)
 
virtual void setOptions ()
 
virtual std::optional< std::string > getVersion ()
 
- Public Member Functions inherited from nix::LogStore
std::optional< std::string > getBuildLog (const StorePath &path)
 

Protected Member Functions

 BinaryCacheStore (const Params &params)
 
- Protected Member Functions inherited from nix::AbstractConfig
 AbstractConfig (StringMap initials={})
 
- Protected Member Functions inherited from nix::Store
 Store (const Params &params)
 
void unsupported (const std::string &op)
 

Protected Attributes

const std::string realisationsPrefix = "realisations"
 
const std::string cacheInfoFile = "nix-cache-info"
 
- Protected Attributes inherited from nix::AbstractConfig
StringMap unknownSettings
 
- Protected Attributes inherited from nix::Store
SharedSync< Statestate
 
std::shared_ptr< NarInfoDiskCachediskCache
 
Stats stats
 

Additional Inherited Members

- Public Types inherited from nix::StoreConfig
using Params = StoreReference::Params
 
- Public Types inherited from nix::Config
using Settings = std::map<std::string, SettingData>
 
- Public Types inherited from nix::Store
using PathsSource = std::vector<std::pair<ValidPathInfo, std::unique_ptr<Source>>>
 
- Static Public Member Functions inherited from nix::StoreConfig
static StringSet getDefaultSystemFeatures ()
 
- Static Public Member Functions inherited from nix::LogStore
static LogStorerequire (Store &store)
 
- Public Attributes inherited from nix::BinaryCacheStoreConfig
const Setting< std::string > compression
 
const Setting< bool > writeNARListing
 
const Setting< bool > writeDebugInfo
 
const Setting< PathsecretKeyFile
 
const Setting< PathlocalNarCache
 
const Setting< bool > parallelCompression
 
const Setting< intcompressionLevel
 
- Public Attributes inherited from nix::StoreConfig
const Setting< intpathInfoCacheSize
 
const Setting< bool > isTrusted
 
Setting< intpriority
 
Setting< bool > wantMassQuery
 
Setting< StringSet > systemFeatures
 
- Public Attributes inherited from nix::StoreDirConfig
const PathSetting storeDir_
 
const Path storeDir = storeDir_
 
- Static Public Attributes inherited from nix::Store
static constexpr const charMissingName = "x"
 
- Static Public Attributes inherited from nix::LogStore
static std::string operationName = "Build log storage and retrieval"
 

Detailed Description

Note
subclasses must implement at least one of the two virtual getFile() methods.

Member Function Documentation

◆ addBuildLog()

void nix::BinaryCacheStore::addBuildLog ( const StorePath & drvPath,
std::string_view log )
overridevirtual

Implements nix::LogStore.

◆ addSignatures()

void nix::BinaryCacheStore::addSignatures ( const StorePath & storePath,
const StringSet & sigs )
overridevirtual

Add signatures to the specified store path. The signatures are not verified.

Reimplemented from nix::Store.

◆ addToStore() [1/2]

void nix::BinaryCacheStore::addToStore ( const ValidPathInfo & info,
Source & narSource,
RepairFlag repair,
CheckSigsFlag checkSigs )
overridevirtual

Import a path into the store.

Implements nix::Store.

◆ addToStore() [2/2]

StorePath nix::BinaryCacheStore::addToStore ( std::string_view name,
const SourcePath & path,
ContentAddressMethod method,
HashAlgorithm hashAlgo,
const StorePathSet & references,
PathFilter & filter,
RepairFlag repair )
overridevirtual

Copy the contents of a path to the store and register the validity the resulting path.

Returns
The resulting path is returned.
Parameters
filterThis function can be used to exclude files (see libutil/archive.hh).

Reimplemented from nix::Store.

◆ addToStoreFromDump()

StorePath nix::BinaryCacheStore::addToStoreFromDump ( Source & dump,
std::string_view name,
FileSerialisationMethod dumpMethod,
ContentAddressMethod hashMethod,
HashAlgorithm hashAlgo,
const StorePathSet & references,
RepairFlag repair )
overridevirtual

Like addToStore(), but the contents of the path are contained in dump, which is either a NAR serialisation (if recursive == true) or simply the contents of a regular file (if recursive == false).

dump may be drained.

Parameters
dumpMethodWhat serialisation format is dump, i.e. how to deserialize it. Must either match hashMethod or be FileSerialisationMethod::NixArchive.
hashMethodHow content addressing? Need not match be the same as dumpMethod.
Todo
remove?

Implements nix::Store.

◆ getBuildLogExact()

std::optional< std::string > nix::BinaryCacheStore::getBuildLogExact ( const StorePath & path)
overridevirtual

Implements nix::LogStore.

◆ getFile() [1/2]

void nix::BinaryCacheStore::getFile ( const std::string & path,
Callback< std::optional< std::string > > callback )
virtualnoexcept

Fetch the specified file and call the specified callback with the result. A subclass may implement this asynchronously.

Reimplemented in nix::HttpBinaryCacheStore.

◆ getFile() [2/2]

void nix::BinaryCacheStore::getFile ( const std::string & path,
Sink & sink )
virtual

Dump the contents of the specified file to a sink.

Reimplemented in nix::HttpBinaryCacheStore, and nix::LocalBinaryCacheStore.

◆ getFSAccessor()

ref< SourceAccessor > nix::BinaryCacheStore::getFSAccessor ( bool requireValidPath = true)
overridevirtual
Returns
An object to access files in the Nix store.

Implements nix::Store.

◆ getNixCacheInfo()

std::optional< std::string > nix::BinaryCacheStore::getNixCacheInfo ( )
virtual

Get the contents of /nix-cache-info. Return std::nullopt if it doesn't exist.

Reimplemented in nix::HttpBinaryCacheStore.

◆ init()

void nix::BinaryCacheStore::init ( )
overridevirtual

Perform any necessary effectful operation to make the store up and running

Reimplemented from nix::Store.

Reimplemented in nix::HttpBinaryCacheStore, and nix::LocalBinaryCacheStore.

◆ isValidPathUncached()

bool nix::BinaryCacheStore::isValidPathUncached ( const StorePath & path)
overridevirtual

Reimplemented from nix::Store.

◆ narFromPath()

void nix::BinaryCacheStore::narFromPath ( const StorePath & path,
Sink & sink )
overridevirtual

Write a NAR dump of a store path.

Implements nix::Store.

◆ queryPathFromHashPart()

std::optional< StorePath > nix::BinaryCacheStore::queryPathFromHashPart ( const std::string & hashPart)
overridevirtual

Query the full store path given the hash part of a valid store path, or empty if the path doesn't exist.

Implements nix::Store.

◆ queryPathInfoUncached()

void nix::BinaryCacheStore::queryPathInfoUncached ( const StorePath & path,
Callback< std::shared_ptr< const ValidPathInfo > > callback )
overridevirtualnoexcept

Implements nix::Store.

◆ queryRealisationUncached()

void nix::BinaryCacheStore::queryRealisationUncached ( const DrvOutput & id,
Callback< std::shared_ptr< const Realisation > > callback )
overridevirtualnoexcept

Implements nix::Store.

◆ registerDrvOutput()

void nix::BinaryCacheStore::registerDrvOutput ( const Realisation & output)
overridevirtual

Add a mapping indicating that deriver!outputName maps to the output path output.

This is redundant for known-input-addressed and fixed-output derivations as this information is already present in the drv file, but necessary for floating-ca derivations and their dependencies as there's no way to retrieve this information otherwise.

Reimplemented from nix::Store.


The documentation for this class was generated from the following files: