Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::Store Class Referenceabstract
Inheritance diagram for nix::Store:
nix::BinaryCacheStore nix::DummyStore nix::GcStore nix::LegacySSHStore nix::LocalFSStore nix::LogStore nix::RemoteStore nix::HttpBinaryCacheStore nix::LocalBinaryCacheStore nix::S3BinaryCacheStore nix::LocalFSStore nix::LocalStore nix::RemoteStore nix::IndirectRootStore nix::BinaryCacheStore nix::LocalFSStore nix::RemoteStore nix::SSHStore nix::UDSRemoteStore

Classes

struct  PathInfoCacheValue
struct  State
struct  AssociatedCredentials
struct  Stats

Public Types

using PathsSource

Public Member Functions

virtual std::optional< AssociatedCredentialsassociatedCredentials () const
virtual kj::Promise< Result< void > > init ()
virtual StoreConfigconfig ()=0
virtual const StoreConfigconfig () const =0
virtual std::string getUri ()=0
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
Path followLinksToStore (std::string_view path) const
StorePath followLinksToStorePath (std::string_view 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 makeTextPath (std::string_view name, const TextInfo &info) const
StorePath makeFixedOutputPathFromCA (std::string_view name, const ContentAddressWithReferences &ca) const
StorePath computeStorePathForPathRecursive (std::string_view name, const PreparedDump &source) const
StorePath computeStorePathForPathFlat (std::string_view name, const Path &srcPath) const
StorePath computeStorePathForText (std::string_view name, std::string_view s, const StorePathSet &references) const
kj::Promise< Result< bool > > isValidPath (const StorePath &path)
kj::Promise< Result< void > > substitutePaths (const StorePathSet &paths)
virtual kj::Promise< Result< StorePathSet > > queryValidPaths (const StorePathSet &paths, SubstituteFlag maybeSubstitute=NoSubstitute)
virtual kj::Promise< Result< StorePathSet > > queryAllValidPaths ()
kj::Promise< Result< ref< const ValidPathInfo > > > queryPathInfo (const StorePath &path)
kj::Promise< Result< std::shared_ptr< const Realisation > > > queryRealisation (const DrvOutput &)
virtual bool pathInfoIsUntrusted (const ValidPathInfo &)
virtual bool realisationIsUntrusted (const Realisation &)
virtual kj::Promise< Result< void > > queryReferrers (const StorePath &path, StorePathSet &referrers)
virtual kj::Promise< Result< StorePathSet > > queryValidDerivers (const StorePath &path)
virtual kj::Promise< Result< StorePathSet > > queryDerivationOutputs (const StorePath &path)
virtual kj::Promise< Result< std::map< std::string, std::optional< StorePath > > > > queryPartialDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
virtual kj::Promise< Result< std::map< std::string, std::optional< StorePath > > > > queryStaticPartialDerivationOutputMap (const StorePath &path)
kj::Promise< Result< OutputPathMap > > queryDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
virtual kj::Promise< Result< std::optional< StorePath > > > queryPathFromHashPart (const std::string &hashPart)=0
virtual kj::Promise< Result< StorePathSet > > querySubstitutablePaths (const StorePathSet &paths)
virtual kj::Promise< Result< void > > querySubstitutablePathInfos (const StorePathCAMap &paths, SubstitutablePathInfos &infos)
virtual kj::Promise< Result< void > > addToStore (const ValidPathInfo &info, AsyncInputStream &narSource, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs)=0
virtual kj::Promise< Result< void > > addMultipleToStore (PathsSource &pathsToCopy, Activity &act, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs)
virtual kj::Promise< Result< StorePath > > addToStoreRecursive (std::string_view name, const PreparedDump &source, HashType hashAlgo=HashType::SHA256, RepairFlag repair=NoRepair)
virtual kj::Promise< Result< StorePath > > addToStoreFlat (std::string_view name, const Path &srcPath, HashType hashAlgo=HashType::SHA256, RepairFlag repair=NoRepair)
kj::Promise< Result< ValidPathInfo > > addToStoreSlow (std::string_view name, const Path &srcPath, FileIngestionMethod method=FileIngestionMethod::Recursive, HashType hashAlgo=HashType::SHA256, std::optional< Hash > expectedCAHash={})
virtual kj::Promise< Result< StorePath > > addToStoreFromDump (AsyncInputStream &dump, std::string_view name, FileIngestionMethod method=FileIngestionMethod::Recursive, HashType hashAlgo=HashType::SHA256, RepairFlag repair=NoRepair, const StorePathSet &references=StorePathSet())
virtual kj::Promise< Result< StorePath > > addTextToStore (std::string_view name, std::string_view s, const StorePathSet &references, RepairFlag repair=NoRepair)=0
virtual kj::Promise< Result< void > > registerDrvOutput (const Realisation &output)
virtual kj::Promise< Result< void > > registerDrvOutput (const Realisation &output, CheckSigsFlag checkSigs)
virtual kj::Promise< Result< box_ptr< Source > > > narFromPath (const StorePath &path)=0
virtual kj::Promise< Result< void > > buildPaths (const std::vector< DerivedPath > &paths, BuildMode buildMode=bmNormal, std::shared_ptr< Store > evalStore=nullptr)
virtual kj::Promise< Result< std::vector< KeyedBuildResult > > > buildPathsWithResults (const std::vector< DerivedPath > &paths, BuildMode buildMode=bmNormal, std::shared_ptr< Store > evalStore=nullptr)
virtual kj::Promise< Result< BuildResult > > buildDerivation (const StorePath &drvPath, const BasicDerivation &drv, BuildMode buildMode=bmNormal)
virtual kj::Promise< Result< void > > ensurePath (const StorePath &path)
virtual kj::Promise< Result< void > > addTempRoot (const StorePath &path)
kj::Promise< Result< std::string > > makeValidityRegistration (const StorePathSet &paths, bool showDerivers, bool showHash)
kj::Promise< Result< JSON > > pathInfoToJSON (const StorePathSet &storePaths, bool includeImpureInfo, bool showClosureSize, Base hashBase=Base::Base32, AllowInvalidFlag allowInvalid=DisallowInvalid)
kj::Promise< Result< std::pair< uint64_t, uint64_t > > > getClosureSize (const StorePath &storePath)
virtual kj::Promise< Result< void > > optimiseStore ()
virtual kj::Promise< Result< bool > > verifyStore (bool checkContents, RepairFlag repair=NoRepair)
virtual ref< FSAccessorgetFSAccessor ()=0
virtual kj::Promise< Result< void > > repairPath (const StorePath &path)
virtual kj::Promise< Result< void > > addSignatures (const StorePath &storePath, const StringSet &sigs)
kj::Promise< Result< Derivation > > derivationFromPath (const StorePath &drvPath)
kj::Promise< Result< Derivation > > readDerivation (const StorePath &drvPath)
kj::Promise< Result< Derivation > > readInvalidDerivation (const StorePath &drvPath)
virtual kj::Promise< Result< void > > computeFSClosure (const StorePathSet &paths, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false)
kj::Promise< Result< void > > computeFSClosure (const StorePath &path, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false)
virtual kj::Promise< Result< void > > queryMissing (const std::vector< DerivedPath > &targets, StorePathSet &willBuild, StorePathSet &willSubstitute, StorePathSet &unknown, uint64_t &downloadSize, uint64_t &narSize)
kj::Promise< Result< StorePaths > > topoSortPaths (const StorePathSet &paths)
kj::Promise< Result< void > > exportPaths (const StorePathSet &paths, Sink &sink)
kj::Promise< Result< void > > exportPath (const StorePath &path, Sink &sink)
kj::Promise< Result< StorePaths > > importPaths (Source &source, CheckSigsFlag checkSigs=CheckSigs)
kj::Promise< Result< Stats<> > > getStats ()
kj::Promise< Result< StorePathSet > > exportReferences (const StorePathSet &storePaths, const StorePathSet &inputPaths)
kj::Promise< Result< std::optional< StorePath > > > getBuildDerivationPath (const StorePath &)
kj::Promise< void > clearPathInfoCache ()
virtual kj::Promise< Result< void > > connect ()
virtual kj::Promise< Result< unsigned int > > getProtocol ()
virtual kj::Promise< Result< std::optional< TrustedFlag > > > isTrustedClient ()=0
virtual Path toRealPath (const Path &storePath)
Path toRealPath (const StorePath &storePath)
virtual kj::Promise< Result< void > > setOptions ()
virtual kj::Promise< Result< std::optional< std::string > > > getVersion ()

Static Public Attributes

static constexpr const char * MissingName = "x"

Protected Member Functions

 Store (const StoreConfig &config)
virtual kj::Promise< Result< bool > > isValidPathUncached (const StorePath &path)
virtual kj::Promise< Result< std::shared_ptr< const ValidPathInfo > > > queryPathInfoUncached (const StorePath &path)=0
virtual kj::Promise< Result< std::shared_ptr< const Realisation > > > queryRealisationUncached (const DrvOutput &)=0
void unsupported (const std::string &op)

Protected Attributes

Sync< State, AsyncMutex > state
std::shared_ptr< NarInfoDiskCachediskCache
Stats< std::atomic > stats

Member Typedef Documentation

◆ PathsSource

Initial value:
std::vector<
std::pair<ValidPathInfo, std::function<kj::Promise<Result<box_ptr<AsyncInputStream>>>()>>>

A list of paths infos along with a source providing the content of the associated store path

Member Function Documentation

◆ addMultipleToStore()

kj::Promise< Result< void > > nix::Store::addMultipleToStore ( PathsSource & pathsToCopy,
Activity & act,
RepairFlag repair = NoRepair,
CheckSigsFlag checkSigs = CheckSigs )
virtual

Import multiple paths into the store.

Reimplemented in nix::RemoteStore.

◆ addSignatures()

virtual kj::Promise< Result< void > > nix::Store::addSignatures ( const StorePath & storePath,
const StringSet & sigs )
inlinevirtual

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

Reimplemented in nix::BinaryCacheStore, nix::LocalStore, and nix::RemoteStore.

◆ addTempRoot()

virtual kj::Promise< Result< void > > nix::Store::addTempRoot ( const StorePath & path)
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.

◆ addTextToStore()

virtual kj::Promise< Result< StorePath > > nix::Store::addTextToStore ( std::string_view name,
std::string_view s,
const StorePathSet & references,
RepairFlag repair = NoRepair )
pure virtual

Like addToStore, but the contents written to the output path is a regular file containing the given string.

Implemented in nix::BinaryCacheStore, nix::DummyStore, nix::LegacySSHStore, nix::LocalStore, and nix::RemoteStore.

◆ addToStore()

virtual kj::Promise< Result< void > > nix::Store::addToStore ( const ValidPathInfo & info,
AsyncInputStream & narSource,
RepairFlag repair = NoRepair,
CheckSigsFlag checkSigs = CheckSigs )
pure virtual

Import a path into the store.

Implemented in nix::BinaryCacheStore, nix::DummyStore, nix::LegacySSHStore, nix::LocalStore, and nix::RemoteStore.

◆ addToStoreFromDump()

virtual kj::Promise< Result< StorePath > > nix::Store::addToStoreFromDump ( AsyncInputStream & dump,
std::string_view name,
FileIngestionMethod method = FileIngestionMethod::Recursive,
HashType hashAlgo = HashType::SHA256,
RepairFlag repair = NoRepair,
const StorePathSet & references = StorePathSet() )
inlinevirtual

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

Todo
remove?

Reimplemented in nix::BinaryCacheStore, nix::LocalStore, and nix::RemoteStore.

◆ addToStoreRecursive()

kj::Promise< Result< StorePath > > nix::Store::addToStoreRecursive ( std::string_view name,
const PreparedDump & source,
HashType hashAlgo = HashType::SHA256,
RepairFlag repair = NoRepair )
virtual

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 in nix::BinaryCacheStore, and nix::LegacySSHStore.

◆ addToStoreSlow()

kj::Promise< Result< ValidPathInfo > > nix::Store::addToStoreSlow ( std::string_view name,
const Path & srcPath,
FileIngestionMethod method = FileIngestionMethod::Recursive,
HashType hashAlgo = HashType::SHA256,
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.

◆ associatedCredentials()

virtual std::optional< AssociatedCredentials > nix::Store::associatedCredentials ( ) const
inlinevirtual

Credentials of the context using this store if this store is proxied to somewhere else and the peer context is known. Only the daemon can set this to values that make any sense, using unix peer credentials.

Reimplemented in nix::LocalStore.

◆ buildDerivation()

kj::Promise< Result< BuildResult > > nix::Store::buildDerivation ( const StorePath & drvPath,
const BasicDerivation & drv,
BuildMode buildMode = bmNormal )
virtual

Build a single non-materialized derivation (i.e. not from an on-disk .drv file).

Parameters
drvPathThis 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:

  • It keeps the operation trustless, by ruling out a maliciously invalid drv path corresponding to a non-resolution-equivalent derivation.
  • For the floating case in particular, it ensures that the derivation to output mapping respects the resolution equivalence relation, so one cannot choose different resolution-equivalent derivations to subvert dependency coherence (i.e. the property that one doesn't end up with multiple different versions of dependencies without explicitly choosing to allow it).

Reimplemented in nix::LegacySSHStore, and nix::RemoteStore.

◆ buildPaths()

kj::Promise< Result< void > > nix::Store::buildPaths ( const std::vector< DerivedPath > & paths,
BuildMode buildMode = bmNormal,
std::shared_ptr< Store > evalStore = nullptr )
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.

◆ buildPathsWithResults()

kj::Promise< Result< std::vector< KeyedBuildResult > > > nix::Store::buildPathsWithResults ( const std::vector< DerivedPath > & paths,
BuildMode buildMode = bmNormal,
std::shared_ptr< Store > evalStore = nullptr )
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.

◆ clearPathInfoCache()

kj::Promise< void > nix::Store::clearPathInfoCache ( )
inline

Hack to allow long-running processes like hydra-queue-runner to occasionally flush their path info cache.

◆ computeFSClosure()

kj::Promise< Result< void > > nix::Store::computeFSClosure ( const StorePathSet & paths,
StorePathSet & out,
bool flipDirection = false,
bool includeOutputs = false,
bool includeDerivers = false )
virtual
Parameters
[out]outPlace 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.
flipDirectionIf 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.

◆ computeStorePathForPathRecursive()

StorePath nix::Store::computeStorePathForPathRecursive ( std::string_view name,
const PreparedDump & source ) const

Preparatory part of addToStore().

Returns
the store path to which srcPath is to be copied.

◆ computeStorePathForText()

StorePath nix::Store::computeStorePathForText ( std::string_view name,
std::string_view s,
const StorePathSet & references ) const

Preparatory part of addTextToStore().

!!! Computation of the path should take the references given to addTextToStore() into account, otherwise we have a (relatively minor) security hole: a caller can register a source file with bogus references. If there are too many references, the path may not be garbage collected when it has to be (not really a problem, the caller could create a root anyway), or it may be garbage collected when it shouldn't be (more serious).

Hashing the references would solve this (bogus references would simply yield a different store path, so other users wouldn't be affected), but it has some backwards compatibility issues (the hashing scheme changes), so I'm not doing that for now.

◆ connect()

virtual kj::Promise< Result< void > > nix::Store::connect ( )
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.

◆ derivationFromPath()

kj::Promise< Result< Derivation > > nix::Store::derivationFromPath ( const StorePath & drvPath)

Read a derivation, after ensuring its existence through ensurePath().

◆ ensurePath()

kj::Promise< Result< void > > nix::Store::ensurePath ( const StorePath & path)
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.

◆ exportPaths()

kj::Promise< Result< void > > nix::Store::exportPaths ( const StorePathSet & paths,
Sink & sink )

Export multiple paths in the format expected by ‘nix-store –import’.

◆ exportReferences()

kj::Promise< Result< 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.

◆ followLinksToStore()

Path nix::Store::followLinksToStore ( std::string_view path) const

Follow symlinks until we end up with a path in the Nix store.

◆ followLinksToStorePath()

StorePath nix::Store::followLinksToStorePath ( std::string_view path) const

Same as followLinksToStore(), but apply toStorePath() to the result.

◆ getBuildDerivationPath()

kj::Promise< Result< std::optional< StorePath > > > nix::Store::getBuildDerivationPath ( const StorePath & path)

Given a store path, return the realisation actually used in the realisation of this path:

  • If the path is a content-addressed derivation, try to resolve it
  • Otherwise, find one of its derivers

◆ getClosureSize()

kj::Promise< Result< std::pair< uint64_t, uint64_t > > > nix::Store::getClosureSize ( const StorePath & storePath)
Returns
the size of the closure of the specified path, that is, the sum of the size of the NAR serialisation of each path in the closure.

◆ getFSAccessor()

virtual ref< FSAccessor > nix::Store::getFSAccessor ( )
pure virtual
Returns
An object to access files in the Nix store.

Implemented in nix::BinaryCacheStore, nix::DummyStore, nix::LegacySSHStore, nix::LocalFSStore, nix::RemoteStore, and nix::UDSRemoteStore.

◆ getProtocol()

virtual kj::Promise< Result< unsigned int > > nix::Store::getProtocol ( )
inlinevirtual

Get the protocol version of this store or it's connection.

Reimplemented in nix::LegacySSHStore, nix::LocalStore, and nix::RemoteStore.

◆ getUri()

std::string nix::Store::getUri ( )
pure virtual

Implemented in nix::LocalStore.

◆ importPaths()

kj::Promise< Result< 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.

◆ init()

virtual kj::Promise< Result< void > > nix::Store::init ( )
inlinevirtual

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

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

◆ isInStore()

bool nix::Store::isInStore ( PathView path) const
Returns
true if ‘path’ is in the Nix store (but not the Nix store itself).

◆ isStorePath()

bool nix::Store::isStorePath ( std::string_view path) const
Returns
true if ‘path’ is a store path, i.e. a direct child of the Nix store.

◆ isTrustedClient()

virtual kj::Promise< Result< std::optional< TrustedFlag > > > nix::Store::isTrustedClient ( )
pure virtual
Returns
/ whether store trusts us.

std::nullopt means we do not know.

Note
This is the opposite of the StoreConfig::isTrusted store setting. That is about whether we trust the store.

Implemented in nix::DummyStore, nix::HttpBinaryCacheStore, nix::LegacySSHStore, nix::LocalBinaryCacheStore, nix::LocalStore, and nix::RemoteStore.

◆ isValidPath()

kj::Promise< Result< bool > > nix::Store::isValidPath ( const StorePath & path)

Check whether a path is valid. A path is valid when it exists in the store now.

◆ makeStorePath()

StorePath nix::Store::makeStorePath ( std::string_view type,
std::string_view hash,
std::string_view name ) const

Constructs a unique store path name.

◆ makeValidityRegistration()

kj::Promise< Result< std::string > > nix::Store::makeValidityRegistration ( const StorePathSet & paths,
bool showDerivers,
bool showHash )
Returns
a string representing information about the path that can be loaded into the database using nix-store --load-db or nix-store --register-validity.

◆ narFromPath()

virtual kj::Promise< Result< box_ptr< Source > > > nix::Store::narFromPath ( const StorePath & path)
pure virtual

◆ optimiseStore()

virtual kj::Promise< Result< void > > nix::Store::optimiseStore ( )
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.

◆ parseStorePathSet()

StorePathSet nix::Store::parseStorePathSet ( const PathSet & paths) const

Deprecated

Todo
remove

◆ pathInfoIsUntrusted()

virtual bool nix::Store::pathInfoIsUntrusted ( const ValidPathInfo & )
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.

◆ pathInfoToJSON()

kj::Promise< Result< JSON > > nix::Store::pathInfoToJSON ( const StorePathSet & storePaths,
bool includeImpureInfo,
bool showClosureSize,
Base hashBase = Base::Base32,
AllowInvalidFlag allowInvalid = DisallowInvalid )

Write a JSON representation of store path metadata, such as the hash and the references.

Parameters
includeImpureInfoIf true, variable elements such as the registration time are included.
showClosureSizeIf true, the closure size of each path is included.

◆ queryAllValidPaths()

virtual kj::Promise< Result< StorePathSet > > nix::Store::queryAllValidPaths ( )
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.

◆ queryDerivationOutputMap()

kj::Promise< Result< 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.

◆ queryDerivationOutputs()

kj::Promise< Result< StorePathSet > > nix::Store::queryDerivationOutputs ( const StorePath & path)
virtual

Query the outputs of the derivation denoted by path.

Reimplemented in nix::RemoteStore.

◆ queryMissing()

kj::Promise< Result< void > > nix::Store::queryMissing ( const std::vector< DerivedPath > & targets,
StorePathSet & willBuild,
StorePathSet & willSubstitute,
StorePathSet & unknown,
uint64_t & downloadSize,
uint64_t & narSize )
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.

◆ queryPartialDerivationOutputMap()

kj::Promise< Result< std::map< std::string, std::optional< StorePath > > > > nix::Store::queryPartialDerivationOutputMap ( const StorePath & path,
Store * evalStore = nullptr )
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.

◆ queryPathFromHashPart()

virtual kj::Promise< Result< std::optional< StorePath > > > nix::Store::queryPathFromHashPart ( const std::string & hashPart)
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.

◆ queryPathInfo()

kj::Promise< Result< 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.

◆ queryPathInfoUncached()

virtual kj::Promise< Result< std::shared_ptr< const ValidPathInfo > > > nix::Store::queryPathInfoUncached ( const StorePath & path)
protectedpure virtual

Queries the path info without caching. Note to implementors: should return nullptr when the path is not found.

Implemented in nix::BinaryCacheStore, nix::DummyStore, nix::LegacySSHStore, nix::LocalStore, and nix::RemoteStore.

◆ queryRealisation()

kj::Promise< Result< std::shared_ptr< const Realisation > > > nix::Store::queryRealisation ( const DrvOutput & id)

Query the information about a realisation.

◆ queryReferrers()

virtual kj::Promise< Result< void > > nix::Store::queryReferrers ( const StorePath & path,
StorePathSet & referrers )
inlinevirtual

Queries the set of incoming FS references for a store path. The result is not cleared.

Reimplemented in nix::LocalStore, and nix::RemoteStore.

◆ queryStaticPartialDerivationOutputMap()

kj::Promise< Result< std::map< std::string, std::optional< StorePath > > > > nix::Store::queryStaticPartialDerivationOutputMap ( const StorePath & path)
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.

◆ querySubstitutablePathInfos()

kj::Promise< Result< void > > nix::Store::querySubstitutablePathInfos ( const StorePathCAMap & paths,
SubstitutablePathInfos & infos )
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.

◆ querySubstitutablePaths()

virtual kj::Promise< Result< StorePathSet > > nix::Store::querySubstitutablePaths ( const StorePathSet & paths)
inlinevirtual

Query which of the given paths have substitutes.

Reimplemented in nix::LocalStore, and nix::RemoteStore.

◆ queryValidDerivers()

virtual kj::Promise< Result< StorePathSet > > nix::Store::queryValidDerivers ( const StorePath & path)
inlinevirtual
Returns
all currently valid derivations that have 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.

◆ queryValidPaths()

kj::Promise< Result< StorePathSet > > nix::Store::queryValidPaths ( const StorePathSet & paths,
SubstituteFlag maybeSubstitute = NoSubstitute )
virtual

Query which of the given paths is valid. Optionally, try to substitute missing paths.

Reimplemented in nix::LegacySSHStore, nix::LocalStore, and nix::RemoteStore.

◆ readDerivation()

kj::Promise< Result< Derivation > > nix::Store::readDerivation ( const StorePath & drvPath)

Read a derivation (which must already be valid).

◆ readInvalidDerivation()

kj::Promise< Result< Derivation > > nix::Store::readInvalidDerivation ( const StorePath & drvPath)

Read a derivation from a potentially invalid path.

◆ registerDrvOutput()

virtual kj::Promise< Result< void > > nix::Store::registerDrvOutput ( const Realisation & output)
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.

◆ repairPath()

kj::Promise< Result< void > > nix::Store::repairPath ( const StorePath & path)
virtual

Repair the contents of the given path by redownloading it using a substituter (if available).

Reimplemented in nix::LegacySSHStore, and nix::RemoteStore.

◆ setOptions()

virtual kj::Promise< Result< void > > nix::Store::setOptions ( )
inlinevirtual

Synchronises the options of the client with those of the daemon (a no-op when there’s no daemon)

Reimplemented in nix::RemoteStore.

◆ showPaths()

std::string nix::Store::showPaths ( const StorePathSet & paths)

Display a set of paths in human-readable form (i.e., between quotes and separated by commas).

◆ substitutePaths()

kj::Promise< Result< void > > nix::Store::substitutePaths ( const StorePathSet & paths)

If requested, substitute missing paths. This implements nix-copy-closure's –use-substitutes flag.

◆ topoSortPaths()

kj::Promise< Result< 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.

◆ toStorePath()

std::pair< StorePath, Path > nix::Store::toStorePath ( PathView path) const

Split a path like /nix/store/<hash>-<name>/<bla> into /nix/store/<hash>-<name> and /<bla>.

◆ unsupported()

void nix::Store::unsupported ( const std::string & op)
inlineprotected

Helper for methods that are not unsupported: this is used for default definitions for virtual methods that are meant to be overriden.

Todo
Using this should be a last resort. It is better to make the method "virtual pure" and/or move it to a subclass.

◆ verifyStore()

virtual kj::Promise< Result< bool > > nix::Store::verifyStore ( bool checkContents,
RepairFlag repair = NoRepair )
inlinevirtual

Check the integrity of the Nix store.

Returns
true if errors remain.

Reimplemented in nix::LocalStore, and nix::RemoteStore.


The documentation for this class was generated from the following files:
  • lix/libstore/store-api.hh
  • lix/libstore/export-import.cc
  • lix/libstore/misc.cc
  • lix/libstore/path.cc
  • lix/libstore/store-api.cc
  • lix/libstore/build/entry-points.cc