Classes | |
struct | PathInfoCacheValue |
struct | State |
struct | Stats |
Public Types | |
using | PathsSource = std::vector<std::pair<ValidPathInfo, std::unique_ptr<Source>>> |
![]() | |
using | Params = StoreReference::Params |
![]() | |
using | Settings = std::map<std::string, SettingData> |
Public Member Functions | |
virtual void | init () |
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 ValidPathInfo > | queryPathInfo (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 Realisation > | queryRealisation (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 std::optional< StorePath > | queryPathFromHashPart (const std::string &hashPart)=0 |
virtual StorePathSet | querySubstitutablePaths (const StorePathSet &paths) |
virtual void | querySubstitutablePathInfos (const StorePathCAMap &paths, SubstitutablePathInfos &infos) |
virtual void | addToStore (const ValidPathInfo &info, Source &narSource, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs)=0 |
virtual void | addMultipleToStore (Source &source, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs) |
virtual void | addMultipleToStore (PathsSource &&pathsToCopy, Activity &act, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs) |
virtual StorePath | addToStore (std::string_view name, const SourcePath &path, ContentAddressMethod method=ContentAddressMethod::Raw::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references=StorePathSet(), PathFilter &filter=defaultPathFilter, RepairFlag repair=NoRepair) |
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 StorePath | addToStoreFromDump (Source &dump, std::string_view name, FileSerialisationMethod dumpMethod=FileSerialisationMethod::NixArchive, ContentAddressMethod hashMethod=ContentAddressMethod::Raw::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references=StorePathSet(), RepairFlag repair=NoRepair)=0 |
virtual void | registerDrvOutput (const Realisation &output) |
virtual void | registerDrvOutput (const Realisation &output, CheckSigsFlag checkSigs) |
virtual void | narFromPath (const StorePath &path, Sink &sink)=0 |
virtual void | buildPaths (const std::vector< DerivedPath > &paths, BuildMode buildMode=bmNormal, std::shared_ptr< Store > evalStore=nullptr) |
virtual std::vector< KeyedBuildResult > | buildPathsWithResults (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 ref< SourceAccessor > | getFSAccessor (bool requireValidPath=true)=0 |
virtual void | repairPath (const StorePath &path) |
virtual void | addSignatures (const StorePath &storePath, const StringSet &sigs) |
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 Stats & | getStats () |
StorePathSet | exportReferences (const StorePathSet &storePaths, const StorePathSet &inputPaths) |
std::optional< StorePath > | getBuildDerivationPath (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 () |
![]() | |
virtual const std::string | name ()=0 |
virtual std::string | doc () |
virtual std::optional< ExperimentalFeature > | experimentalFeature () const |
StoreDirConfig ()=delete | |
![]() | |
StorePath | parseStorePath (std::string_view path) const |
std::optional< StorePath > | maybeParseStorePath (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, Path > | toStorePath (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, Hash > | computeStorePath (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={}) | |
![]() | |
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 |
![]() | |
void | applyConfig (const std::string &contents, const std::string &path="<unknown>") |
void | warnUnknownSettings () |
void | reapplyUnknownSettings () |
Static Public Attributes | |
static constexpr const char * | MissingName = "x" |
Protected Member Functions | |
Store (const Params ¶ms) | |
virtual bool | isValidPathUncached (const StorePath &path) |
virtual void | queryPathInfoUncached (const StorePath &path, Callback< std::shared_ptr< const ValidPathInfo > > callback) noexcept=0 |
virtual void | queryRealisationUncached (const DrvOutput &, Callback< std::shared_ptr< const Realisation > > callback) noexcept=0 |
void | unsupported (const std::string &op) |
![]() | |
AbstractConfig (StringMap initials={}) | |
Protected Attributes | |
SharedSync< State > | state |
std::shared_ptr< NarInfoDiskCache > | diskCache |
Stats | stats |
![]() | |
StringMap | unknownSettings |
Additional Inherited Members | |
![]() | |
static StringSet | getDefaultSystemFeatures () |
![]() | |
const Setting< int > | pathInfoCacheSize |
const Setting< bool > | isTrusted |
Setting< int > | priority |
Setting< bool > | wantMassQuery |
Setting< StringSet > | systemFeatures |
![]() | |
const PathSetting | storeDir_ |
const Path | storeDir = storeDir_ |
using nix::Store::PathsSource = std::vector<std::pair<ValidPathInfo, std::unique_ptr<Source>>> |
A list of paths infos along with a source providing the content of the associated store path
|
virtual |
Import multiple paths into the store.
Reimplemented in nix::RemoteStore.
|
inlinevirtual |
Add signatures to the specified store path. The signatures are not verified.
Reimplemented in nix::BinaryCacheStore, nix::LocalStore, and nix::RemoteStore.
|
inlinevirtual |
Add a store path as a temporary root of the garbage collector. The root disappears as soon as we exit.
Reimplemented in nix::LocalStore, and nix::RemoteStore.
|
pure virtual |
Import a path into the store.
Implemented in nix::BinaryCacheStore, nix::DummyStore, nix::LegacySSHStore, nix::LocalStore, and nix::RemoteStore.
|
virtual |
Copy the contents of a path to the store and register the validity the resulting path.
filter | This function can be used to exclude files (see libutil/archive.hh). |
Reimplemented in nix::BinaryCacheStore, and nix::LegacySSHStore.
|
pure virtual |
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.
dumpMethod | What serialisation format is dump , i.e. how to deserialize it. Must either match hashMethod or be FileSerialisationMethod::NixArchive . |
hashMethod | How content addressing? Need not match be the same as dumpMethod . |
Implemented in nix::BinaryCacheStore, nix::DummyStore, nix::LegacySSHStore, nix::LocalStore, and nix::RemoteStore.
ValidPathInfo nix::Store::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 = {} ) |
Copy the contents of a path to the store and register the validity the resulting path, using a constant amount of memory.
|
virtual |
Build a single non-materialized derivation (i.e. not from an on-disk .drv file).
drvPath | This is used to deduplicate worker goals so it is imperative that is correct. That said, it doesn't literally need to be store path that would be calculated from writing this derivation to the store: it is OK if it instead is that of a Derivation which would resolve to this (by taking the outputs of it's input derivations and adding them as input sources) such that the build time referenceable-paths are the same. |
In the input-addressed case, we usually do use an "original" unresolved derivations's path, as that is what will be used in the buildPaths case. Also, the input-addressed output paths are verified only by that contents of that specific unresolved derivation, so it is nice to keep that information around so if the original derivation is ever obtained later, it can be verified whether the trusted user in fact used the proper output path.
In the content-addressed case, we want to always use the resolved drv path calculated from the provided derivation. This serves two purposes:
Reimplemented in nix::LegacySSHStore, and nix::RemoteStore.
|
virtual |
For each path, if it's a derivation, build it. Building a derivation means ensuring that the output paths are valid. If they are already valid, this is a no-op. Otherwise, validity can be reached in two ways. First, if the output paths is substitutable, then build the path that way. Second, the output paths can be created by running the builder, after recursively building any sub-derivations. For inputs that are not derivations, substitute them.
Reimplemented in nix::LegacySSHStore, and nix::RemoteStore.
|
virtual |
Like buildPaths(), but return a vector of BuildResult BuildResults corresponding to each element in paths. Note that in case of a build/substitution error, this function won't throw an exception, but return a BuildResult containing an error message.
Reimplemented in nix::RemoteStore.
|
inline |
Hack to allow long-running processes like hydra-queue-runner to occasionally flush their path info cache.
|
virtual |
[out] | out | Place in here the set of all store paths in the file system closure of storePath ; that is, all paths than can be directly or indirectly reached from it. out is not cleared. |
flipDirection | If true, the set of paths that can reach storePath is returned; that is, the closures under the referrers relation instead of the references relation is returned. |
Reimplemented in nix::LegacySSHStore.
|
inlinevirtual |
Establish a connection to the store, for store types that have a notion of connection. Otherwise this is a no-op.
Reimplemented in nix::LegacySSHStore, and nix::RemoteStore.
Derivation nix::Store::derivationFromPath | ( | const StorePath & | drvPath | ) |
Read a derivation, after ensuring its existence through ensurePath().
|
virtual |
Ensure that a path is valid. If it is not currently valid, it may be made valid by running a substitute (if defined for the path).
Reimplemented in nix::LegacySSHStore, and nix::RemoteStore.
void nix::Store::exportPaths | ( | const StorePathSet & | paths, |
Sink & | sink ) |
Export multiple paths in the format expected by ‘nix-store –import’.
StorePathSet nix::Store::exportReferences | ( | const StorePathSet & | storePaths, |
const StorePathSet & | inputPaths ) |
Computes the full closure of of a set of store-paths for e.g. derivations that need this information for exportReferencesGraph
.
Path nix::Store::followLinksToStore | ( | std::string_view | path | ) | const |
Follow symlinks until we end up with a path in the Nix store.
StorePath nix::Store::followLinksToStorePath | ( | std::string_view | path | ) | const |
Same as followLinksToStore(), but apply toStorePath() to the result.
Given a store path, return the realisation actually used in the realisation of this path:
|
pure virtual |
Implemented in nix::BinaryCacheStore, nix::DummyStore, nix::LegacySSHStore, nix::LocalFSStore, nix::MountedSSHStore, nix::RemoteStore, and nix::UDSRemoteStore.
|
inlinevirtual |
Get the protocol version of this store or it's connection.
Reimplemented in nix::LegacySSHStore, nix::LocalStore, and nix::RemoteStore.
|
pure virtual |
StoreConfig
one we store enough information in those to recover the scheme and authority in all cases. Implemented in nix::DummyStore, nix::HttpBinaryCacheStore, nix::LegacySSHStore, nix::LocalBinaryCacheStore, nix::LocalOverlayStore, nix::LocalStore, nix::MountedSSHStore, nix::SSHStore, and nix::UDSRemoteStore.
StorePaths nix::Store::importPaths | ( | Source & | source, |
CheckSigsFlag | checkSigs = CheckSigs ) |
Import a sequence of NAR dumps created by exportPaths() into the Nix store. Optionally, the contents of the NARs are preloaded into the specified FS accessor to speed up subsequent access.
|
inlinevirtual |
Perform any necessary effectful operation to make the store up and running
Reimplemented in nix::BinaryCacheStore, nix::HttpBinaryCacheStore, and nix::LocalBinaryCacheStore.
|
pure virtual |
std::nullopt
means we do not know.
Implemented in nix::DummyStore, nix::HttpBinaryCacheStore, nix::LegacySSHStore, nix::LocalBinaryCacheStore, nix::LocalStore, and nix::RemoteStore.
bool nix::Store::isValidPath | ( | const StorePath & | path | ) |
Check whether a path is valid.
std::string nix::Store::makeValidityRegistration | ( | const StorePathSet & | paths, |
bool | showDerivers, | ||
bool | showHash ) |
nix-store --load-db
or nix-store --register-validity
. Write a NAR dump of a store path.
Implemented in nix::BinaryCacheStore, nix::DummyStore, nix::LegacySSHStore, nix::LocalFSStore, nix::MountedSSHStore, nix::RemoteStore, and nix::UDSRemoteStore.
|
inlinevirtual |
Optimise the disk space usage of the Nix store by hard-linking files with the same contents.
Reimplemented in nix::LocalStore, and nix::RemoteStore.
|
inlinevirtual |
Check whether the given valid path info is sufficiently attested, by either being signed by a trusted public key or content-addressed, in order to be included in the given store.
These same checks would be performed in addToStore, but this allows an earlier failure in the case where dependencies need to be added too, but the addToStore wouldn't fail until those dependencies are added. Also, we don't really want to add the dependencies listed in a nar info we don't trust anyyways.
Reimplemented in nix::LocalStore.
|
inlinevirtual |
Query the set of all valid paths. Note that for some store backends, the name part of store paths may be replaced by x
(i.e. you'll get /nix/store/<hash>-x
rather than /nix/store/<hash>-<name>
). Use queryPathInfo() to obtain the full store path. FIXME: should return a set of std::variant<StorePath, HashPart>
to get rid of this hack.
Reimplemented in nix::LocalBinaryCacheStore, nix::LocalStore, and nix::RemoteStore.
OutputPathMap nix::Store::queryDerivationOutputMap | ( | const StorePath & | path, |
Store * | evalStore = nullptr ) |
Query the mapping outputName=>outputPath for the given derivation. Assume every output has a mapping and throw an exception otherwise.
|
virtual |
Query the outputs of the derivation denoted by path
.
Reimplemented in nix::RemoteStore.
|
virtual |
Given a set of paths that are to be built, return the set of derivations that will be built, and the set of output paths that will be substituted.
Reimplemented in nix::RemoteStore.
|
virtual |
Query the mapping outputName => outputPath for the given derivation. All outputs are mentioned so ones mising the mapping are mapped to std::nullopt
.
Reimplemented in nix::RemoteStore.
|
pure virtual |
Query the full store path given the hash part of a valid store path, or empty if the path doesn't exist.
Implemented in nix::BinaryCacheStore, nix::DummyStore, nix::LegacySSHStore, nix::LocalStore, and nix::RemoteStore.
ref< const ValidPathInfo > nix::Store::queryPathInfo | ( | const StorePath & | path | ) |
Query information about a valid path. It is permitted to omit the name part of the store path.
|
noexcept |
Asynchronous version of queryPathInfo().
std::optional< std::shared_ptr< const ValidPathInfo > > nix::Store::queryPathInfoFromClientCache | ( | const StorePath & | path | ) |
Version of queryPathInfo() that only queries the local narinfo cache and not the actual store.
std::nullopt
if nothing is known about the path in the local narinfo cache. std::make_optional(nullptr)
if the path is known to not exist. std::make_optional(validPathInfo)
if the path is known to exist. std::shared_ptr< const Realisation > nix::Store::queryRealisation | ( | const DrvOutput & | id | ) |
Query the information about a realisation.
|
noexcept |
Asynchronous version of queryRealisation().
|
inlinevirtual |
Queries the set of incoming FS references for a store path. The result is not cleared.
Reimplemented in nix::LocalStore, and nix::RemoteStore.
|
virtual |
Like queryPartialDerivationOutputMap
but only considers statically known output paths (i.e. those that can be gotten from the derivation itself.
Just a helper function for implementing queryPartialDerivationOutputMap
.
Reimplemented in nix::LocalStore.
|
virtual |
Query substitute info (i.e. references, derivers and download sizes) of a map of paths to their optional ca values. The info of the first succeeding substituter for each path will be returned. If a path does not have substitute info, it's omitted from the resulting ‘infos’ map.
Reimplemented in nix::RemoteStore.
|
inlinevirtual |
Query which of the given paths have substitutes.
Reimplemented in nix::LocalStore, and nix::RemoteStore.
|
inlinevirtual |
path
as an output.(Note that the result of queryDeriver()
is the derivation that was actually used to produce path
, which may not exist anymore.)
Reimplemented in nix::LocalStore, and nix::RemoteStore.
|
virtual |
Query which of the given paths is valid. Optionally, try to substitute missing paths.
Reimplemented in nix::LegacySSHStore, nix::LocalStore, and nix::RemoteStore.
Derivation nix::Store::readDerivation | ( | const StorePath & | drvPath | ) |
Read a derivation (which must already be valid).
Derivation nix::Store::readInvalidDerivation | ( | const StorePath & | drvPath | ) |
Read a derivation from a potentially invalid path.
|
inlinevirtual |
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 in nix::BinaryCacheStore, nix::LocalStore, and nix::RemoteStore.
|
virtual |
Repair the contents of the given path by redownloading it using a substituter (if available).
Reimplemented in nix::LegacySSHStore, and nix::RemoteStore.
|
inlinevirtual |
Synchronises the options of the client with those of the daemon (a no-op when there’s no daemon)
Reimplemented in nix::RemoteStore.
void nix::Store::substitutePaths | ( | const StorePathSet & | paths | ) |
If requested, substitute missing paths. This implements nix-copy-closure's –use-substitutes flag.
StorePaths nix::Store::topoSortPaths | ( | const StorePathSet & | paths | ) |
Sort a set of paths topologically under the references relation. If p refers to q, then p precedes q in this list.
|
inlineprotected |
Helper for methods that are not unsupported: this is used for default definitions for virtual methods that are meant to be overriden.
|
inlinevirtual |
Check the integrity of the Nix store.
Reimplemented in nix::LocalStore, and nix::RemoteStore.