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

#include <store-api.hh>

Inheritance diagram for nix::Store:
nix::StoreDirConfig nix::BinaryCacheStore nix::DummyStore nix::GcStore nix::LegacySSHStore nix::LocalFSStore nix::LogStore nix::RemoteStore nix::SubmitStore

Classes

struct  PathInfoCacheValue

Public Types

using Config = StoreConfig
using PathsSource = std::vector<std::pair<ValidPathInfo, std::unique_ptr<Source>>>

Public Member Functions

 operator const Config & () const
virtual void init ()
virtual ref< Builder > getBuilder (std::shared_ptr< Store > evalStore=nullptr)
std::filesystem::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 UnkeyedRealisation > queryRealisation (const DrvOutput &)
void queryRealisation (const DrvOutput &, Callback< std::shared_ptr< const UnkeyedRealisation > > 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)
virtual std::optional< StorePath > queryStaticPartialDerivationOutput (const StorePath &path, const std::string &outputName)
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 (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, CheckSigsFlag checkSigs)
virtual void narFromPath (const StorePath &path, Sink &sink)
virtual void addTempRoot (const StorePath &path)
virtual void addTempRoots (const StorePathSet &paths)
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 std::shared_ptr< SourceAccessor > getFSAccessor (const StorePath &path, bool requireValidPath=true)=0
ref< SourceAccessor > requireStoreObjectAccessor (const StorePath &path, bool requireValidPath=true)
virtual void addSignatures (const StorePath &storePath, const std::set< Signature > &sigs)
void signPathInfo (ValidPathInfo &info)
void signRealisation (Realisation &)
Derivation derivationFromPath (const StorePath &drvPath)
virtual StorePath writeDerivation (const Derivation &drv, RepairFlag repair=NoRepair)
virtual Derivation readDerivation (const StorePath &drvPath)
virtual 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 MissingPaths queryMissing (const std::vector< DerivedPath > &targets)
virtual StorePaths topoSortPaths (const StorePathSet &paths)
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 void setOptions ()
virtual std::optional< std::string > getVersion ()
Public Member Functions inherited from nix::StoreDirConfig
StorePath parseStorePath (std::string_view path) const
StorePath parseStorePathCanonical (std::string_view path) const
std::optional< StorePath > maybeParseStorePath (std::string_view path) const
std::string printStorePath (const StorePath &path) const
StringSet printStorePathSet (const StorePathSet &path) const
std::size_t maxCanonicalStorePathLen () const noexcept
bool isInStore (std::string_view path) const
bool isStorePath (std::string_view path) const
std::pair< StorePath, CanonPath > toStorePath (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 makeFixedOutputPathFromCA (std::string_view name, const ContentAddressWithReferences &ca) const
std::pair< StorePath, Hash > computeStorePath (std::string_view name, const SourcePath &path, ContentAddressMethod method=ContentAddressMethod::Raw::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references={}, PathFilter &filter=defaultPathFilter) const

Public Attributes

const Config & config
Public Attributes inherited from nix::StoreDirConfig
const std::string & storeDir

Static Public Attributes

static constexpr const char * MissingName = "x"

Protected Member Functions

void invalidatePathInfoCacheFor (const StorePath &path)
 Store (const Store::Config &config)
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 UnkeyedRealisation > > callback) noexcept=0
virtual void registerDrvOutputUnchecked (const Realisation &output)=0
void unsupported (const std::string &op)

Protected Attributes

std::shared_ptr< SharedSync< LRUCache< StorePath, PathInfoCacheValue > > > pathInfoCache
std::shared_ptr< NarInfoDiskCache > diskCache

Detailed Description

A Store (client)

This is an interface type allowing for create and read operations on a collection of store objects, and also building new store objects from Derivations. See the manual for further details.

"client" used is because this is just one view/actor onto an underlying resource, which could be an external process (daemon server), file system state, etc.

Member Typedef Documentation

◆ PathsSource

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

Member Function Documentation

◆ addMultipleToStore()

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

Import multiple paths into the store.

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

◆ addSignatures()

virtual void nix::Store::addSignatures ( const StorePath & storePath,
const std::set< Signature > & sigs )
inlinevirtual

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

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

◆ addTempRoot()

virtual 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. Before exiting, if you want to avoid the path being GC'ed, you either have to make it a permanent root using LocalFSStore::addPermRoot(), or make sure it's reachable from a permanent root (e.g. by adding it as a reference of a reachable path).

To avoid races, you should call either this function or LocalFSStore::addPermRoot() before creating and using a store path, e.g.

auto path = store.computeStorePath(...);
store->addTempRoot(path);
if (!store->isValidPath(path))
store->addToStore(...);

By contrast, registering a root just before using a path is not sufficient to prevent GC races. For instance, don't do this:

store->addTempRoot(path);
auto drv = store->readDerivation(path);

since the path may be GC'ed just before the call to addTempRoot().

Note that addToStore() implicitly calls addTempRoot(), so you don't need to call it yourself if you're calling addToStore() unconditionally.

It is generally the responsibility of the caller of Nix APIs and CLI tools to ensure that paths are reachable by the garbage collector. For example, buildPath(drvPath) does not need to register drvPath as a GC root, since that's the responsibility of the caller, and it would be too late for buildPath() to do so anyway. Thus, this can race:

drv=$(nix-instantiate foo.nix)
nix-store -r $drv

whereas this is safe:

nix-instantiate foo.nix --add-root ./drv
nix-store -r ./drv

Reimplemented in nix::RemoteStore.

◆ addTempRoots()

void nix::Store::addTempRoots ( const StorePathSet & paths)
virtual

Add multiple store paths as temporary roots of the garbage collector. The roots disappears as soon as we exit.

Warning
If you need to add just one path, prefer to use addTempRoot. addTempRoots is implemented on best-effort basis and might be a no-op.

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

◆ addToStore() [1/2]

virtual void nix::Store::addToStore ( const ValidPathInfo & info,
Source & narSource,
RepairFlag repair = NoRepair,
CheckSigsFlag checkSigs = CheckSigs )
pure virtual

Import a path into the store. Note that the entire NAR may not be read from narSource, e.g. if the path is already valid.

Implemented in nix::BinaryCacheStore, nix::DummyStoreImpl, nix::LegacySSHStore, nix::LocalStore, nix::RemoteStore, and nix::RestrictedStore.

◆ addToStore() [2/2]

StorePath nix::Store::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 )
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, nix::LegacySSHStore, and nix::RestrictedStore.

◆ addToStoreFromDump()

virtual StorePath nix::Store::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 )
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.

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?

Implemented in nix::BinaryCacheStore, nix::DummyStoreImpl, nix::LegacySSHStore, nix::LocalStore, nix::RemoteStore, and nix::RestrictedStore.

◆ addToStoreSlow()

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.

◆ clearPathInfoCache()

void nix::Store::clearPathInfoCache ( )
inline

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

◆ computeFSClosure()

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.

◆ connect()

virtual 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()

Derivation nix::Store::derivationFromPath ( const StorePath & drvPath)

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

Todo
suspicious to have a Store method that uses getBuilder.

◆ exportReferences()

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()

std::filesystem::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()

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-addressing derivation, try to resolve it
  • Otherwise, find one of its derivers

◆ getBuilder()

ref< Builder > nix::Store::getBuilder ( std::shared_ptr< Store > evalStore = nullptr)
virtual

Get a Builder for this store.

Parameters
evalStoreIf provided and different from this store, derivation files will be copied from the eval store to this store before building.

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

◆ getFSAccessor() [1/2]

virtual ref< SourceAccessor > nix::Store::getFSAccessor ( bool requireValidPath = true)
pure virtual
Returns
An object to access files in the Nix store, across all store objects.

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

◆ getFSAccessor() [2/2]

virtual std::shared_ptr< SourceAccessor > nix::Store::getFSAccessor ( const StorePath & path,
bool requireValidPath = true )
pure virtual
Returns
An object to access files for a specific store object in the Nix store.
nullptr if the store doesn't contain an object at the given path.

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

◆ getProtocol()

virtual 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.

◆ init()

virtual void nix::Store::init ( )
inlinevirtual

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

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

◆ isTrustedClient()

virtual 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::DummyStoreImpl, nix::HttpBinaryCacheStore, nix::LegacySSHStore, nix::LocalBinaryCacheStore, nix::LocalStore, nix::RemoteStore, and nix::RestrictedStore.

◆ isValidPath()

bool nix::Store::isValidPath ( const StorePath & path)

Check whether a path is valid.

◆ isValidPathUncached()

bool nix::Store::isValidPathUncached ( const StorePath & path)
protectedvirtual

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

◆ makeValidityRegistration()

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()

void nix::Store::narFromPath ( const StorePath & path,
Sink & sink )
virtual

◆ operator const Config &()

nix::Store::operator const Config & ( ) const
inline
Note
Avoid churn, since we used to inherit from Config.

◆ optimiseStore()

virtual 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.

◆ 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.

◆ queryAllValidPaths()

virtual 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, nix::RemoteStore, and nix::RestrictedStore.

◆ queryDerivationOutputMap()

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()

StorePathSet nix::Store::queryDerivationOutputs ( const StorePath & path)
virtual

Query the outputs of the derivation denoted by path.

Reimplemented in nix::RemoteStore.

◆ queryMissing()

MissingPaths nix::Store::queryMissing ( const std::vector< DerivedPath > & targets)
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, and nix::RestrictedStore.

◆ queryPartialDerivationOutputMap()

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 missing the mapping are mapped to std::nullopt.

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

◆ queryPathFromHashPart()

virtual 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::DummyStoreImpl, nix::LegacySSHStore, nix::LocalStore, nix::RemoteStore, and nix::RestrictedStore.

◆ queryPathInfo() [1/2]

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.

◆ queryPathInfo() [2/2]

void nix::Store::queryPathInfo ( const StorePath & path,
Callback< ref< const ValidPathInfo > > callback )
noexcept

Asynchronous version of queryPathInfo().

◆ queryPathInfoFromClientCache()

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.

Returns
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.

◆ queryRealisation() [1/2]

std::shared_ptr< const UnkeyedRealisation > nix::Store::queryRealisation ( const DrvOutput & id)

Query the information about a realisation.

◆ queryRealisation() [2/2]

void nix::Store::queryRealisation ( const DrvOutput & id,
Callback< std::shared_ptr< const UnkeyedRealisation > > callback )
noexcept

Asynchronous version of queryRealisation().

◆ queryReferrers()

virtual 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, nix::RemoteStore, and nix::RestrictedStore.

◆ queryStaticPartialDerivationOutput()

std::optional< StorePath > nix::Store::queryStaticPartialDerivationOutput ( const StorePath & path,
const std::string & outputName )
virtual

Like the above, but for a single output.

Reimplemented in nix::LocalStore.

◆ queryStaticPartialDerivationOutputMap()

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()

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()

StorePathSet nix::Store::querySubstitutablePaths ( const StorePathSet & paths)
virtual

Query which of the given paths have substitutes.

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

◆ queryValidDerivers()

virtual 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()

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()

Derivation nix::Store::readDerivation ( const StorePath & drvPath)
virtual

Read a derivation (which must already be valid).

Reimplemented in nix::DummyStoreImpl.

◆ readInvalidDerivation()

Derivation nix::Store::readInvalidDerivation ( const StorePath & drvPath)
virtual

Read a derivation from a potentially invalid path.

Reimplemented in nix::DummyStoreImpl.

◆ registerDrvOutputUnchecked()

virtual void nix::Store::registerDrvOutputUnchecked ( const Realisation & output)
protectedpure virtual

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.

The method that does not perform signature checks is internal only, users should explicitly set the checkSigs argument to NoCheckSigs.

Implemented in nix::BinaryCacheStore, nix::DummyStoreImpl, nix::LegacySSHStore, nix::LocalStore, nix::RemoteStore, and nix::RestrictedStore.

◆ requireStoreObjectAccessor()

ref< SourceAccessor > nix::Store::requireStoreObjectAccessor ( const StorePath & path,
bool requireValidPath = true )
inlinenodiscard

Get an accessor for the store object or throw an Error if it's invalid or doesn't exist.

Exceptions
InvalidPathif the store object doesn't exist or (if requireValidPath = true) is invalid.

◆ setOptions()

virtual 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.

◆ signPathInfo()

void nix::Store::signPathInfo ( ValidPathInfo & info)

Add signatures to a ValidPathInfo or Realisation using the secret keys specified by the ‘secret-key-files’ option.

◆ substitutePaths()

void nix::Store::substitutePaths ( const StorePathSet & paths)

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

Todo
suspicious to have a Store method that uses getBuilder.

◆ topoSortPaths()

StorePaths nix::Store::topoSortPaths ( const StorePathSet & paths)
virtual

Sort a set of paths topologically under the references relation. If p refers to q, then p precedes q in this list. Virtual to allow for more efficient implementations in derived classes.

Reimplemented in nix::HttpBinaryCacheStore.

◆ 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 overridden.

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 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.

◆ writeDerivation()

StorePath nix::Store::writeDerivation ( const Derivation & drv,
RepairFlag repair = NoRepair )
virtual

Write a derivation to the Nix store, and return its path.

Reimplemented in nix::DummyStoreImpl.


The documentation for this class was generated from the following files:
  • libstore/include/nix/store/store-api.hh
  • libstore/derivations.cc
  • libstore/misc.cc
  • libstore/store-api.cc