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

#include <remote-store.hh>

Inheritance diagram for nix::RemoteStore:
nix::RemoteStoreConfig nix::Store nix::GcStore nix::LogStore nix::StoreConfig nix::StoreConfig nix::Store nix::Store nix::StoreDirConfig nix::StoreDirConfig nix::StoreConfig nix::StoreConfig nix::Config nix::Config nix::StoreDirConfig nix::StoreDirConfig nix::AbstractConfig nix::AbstractConfig nix::Config nix::Config nix::AbstractConfig nix::AbstractConfig nix::SSHStore nix::UDSRemoteStore nix::MountedSSHStore

Classes

struct  Connection
 
struct  ConnectionHandle
 

Public Member Functions

 RemoteStore (const Params &params)
 
bool isValidPathUncached (const StorePath &path) override
 
StorePathSet queryValidPaths (const StorePathSet &paths, SubstituteFlag maybeSubstitute=NoSubstitute) override
 
StorePathSet queryAllValidPaths () override
 
void queryPathInfoUncached (const StorePath &path, Callback< std::shared_ptr< const ValidPathInfo > > callback) noexcept override
 
void queryReferrers (const StorePath &path, StorePathSet &referrers) override
 
StorePathSet queryValidDerivers (const StorePath &path) override
 
StorePathSet queryDerivationOutputs (const StorePath &path) override
 
std::map< std::string, std::optional< StorePath > > queryPartialDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr) override
 
std::optional< StorePathqueryPathFromHashPart (const std::string &hashPart) override
 
StorePathSet querySubstitutablePaths (const StorePathSet &paths) override
 
void querySubstitutablePathInfos (const StorePathCAMap &paths, SubstitutablePathInfos &infos) override
 
ref< const ValidPathInfoaddCAToStore (Source &dump, std::string_view name, ContentAddressMethod caMethod, HashAlgorithm hashAlgo, const StorePathSet &references, RepairFlag repair)
 
StorePath addToStoreFromDump (Source &dump, std::string_view name, FileSerialisationMethod dumpMethod=FileSerialisationMethod::NixArchive, ContentAddressMethod hashMethod=FileIngestionMethod::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references=StorePathSet(), RepairFlag repair=NoRepair) override
 
void addToStore (const ValidPathInfo &info, Source &nar, RepairFlag repair, CheckSigsFlag checkSigs) override
 
void addMultipleToStore (Source &source, RepairFlag repair, CheckSigsFlag checkSigs) override
 
void addMultipleToStore (PathsSource &&pathsToCopy, Activity &act, RepairFlag repair, CheckSigsFlag checkSigs) override
 
void registerDrvOutput (const Realisation &info) override
 
void queryRealisationUncached (const DrvOutput &, Callback< std::shared_ptr< const Realisation > > callback) noexcept override
 
void buildPaths (const std::vector< DerivedPath > &paths, BuildMode buildMode, std::shared_ptr< Store > evalStore) override
 
std::vector< KeyedBuildResultbuildPathsWithResults (const std::vector< DerivedPath > &paths, BuildMode buildMode, std::shared_ptr< Store > evalStore) override
 
BuildResult buildDerivation (const StorePath &drvPath, const BasicDerivation &drv, BuildMode buildMode) override
 
void ensurePath (const StorePath &path) override
 
void addTempRoot (const StorePath &path) override
 
Roots findRoots (bool censor) override
 
void collectGarbage (const GCOptions &options, GCResults &results) override
 
void optimiseStore () override
 
bool verifyStore (bool checkContents, RepairFlag repair) override
 
void repairPath (const StorePath &path) override
 
void addSignatures (const StorePath &storePath, const StringSet &sigs) override
 
void queryMissing (const std::vector< DerivedPath > &targets, StorePathSet &willBuild, StorePathSet &willSubstitute, StorePathSet &unknown, uint64_t &downloadSize, uint64_t &narSize) override
 
void addBuildLog (const StorePath &drvPath, std::string_view log) override
 
std::optional< std::string > getVersion () override
 
void connect () override
 
unsigned int getProtocol () override
 
std::optional< TrustedFlag > isTrustedClient () override
 
void flushBadConnections ()
 
ref< ConnectionopenConnectionWrapper ()
 
- Public Member Functions inherited from nix::RemoteStoreConfig
 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 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)
 
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 std::map< std::string, std::optional< StorePath > > queryStaticPartialDerivationOutputMap (const StorePath &path)
 
OutputPathMap queryDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
 
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 void registerDrvOutput (const Realisation &output, CheckSigsFlag checkSigs)
 
std::string makeValidityRegistration (const StorePathSet &paths, bool showDerivers, bool showHash)
 
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)
 
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 Path toRealPath (const Path &storePath)
 
Path toRealPath (const StorePath &storePath)
 
- Public Member Functions inherited from nix::LogStore
std::optional< std::string > getBuildLog (const StorePath &path)
 
virtual std::optional< std::string > getBuildLogExact (const StorePath &path)=0
 

Protected Member Functions

virtual ref< ConnectionopenConnection ()=0
 
void initConnection (Connection &conn)
 
virtual void setOptions (Connection &conn)
 
void setOptions () override
 
ConnectionHandle getConnection ()
 
virtual ref< SourceAccessorgetFSAccessor (bool requireValidPath=true) override
 
virtual void narFromPath (const StorePath &path, Sink &sink) override
 
- 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

ref< Pool< Connection > > connections
 
- Protected Attributes inherited from nix::AbstractConfig
StringMap unknownSettings
 
- Protected Attributes inherited from nix::Store
SharedSync< Statestate
 
std::shared_ptr< NarInfoDiskCachediskCache
 
Stats stats
 

Friends

struct ConnectionHandle
 

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::RemoteStoreConfig
const Setting< intmaxConnections
 
const Setting< unsigned intmaxConnectionAge
 
- 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::GcStore
static std::string operationName = "Garbage collection"
 
- Static Public Attributes inherited from nix::LogStore
static std::string operationName = "Build log storage and retrieval"
 

Detailed Description

Todo
RemoteStore is a misnomer - should be something like DaemonStore.

Member Function Documentation

◆ addBuildLog()

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

Implements nix::LogStore.

◆ addCAToStore()

ref< const ValidPathInfo > nix::RemoteStore::addCAToStore ( Source & dump,
std::string_view name,
ContentAddressMethod caMethod,
HashAlgorithm hashAlgo,
const StorePathSet & references,
RepairFlag repair )

Add a content-addressable store path. dump will be drained.

◆ addMultipleToStore() [1/2]

void nix::RemoteStore::addMultipleToStore ( PathsSource && pathsToCopy,
Activity & act,
RepairFlag repair,
CheckSigsFlag checkSigs )
overridevirtual

Reimplemented from nix::Store.

◆ addMultipleToStore() [2/2]

void nix::RemoteStore::addMultipleToStore ( Source & source,
RepairFlag repair,
CheckSigsFlag checkSigs )
overridevirtual

Import multiple paths into the store.

Reimplemented from nix::Store.

◆ addSignatures()

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

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

Reimplemented from nix::Store.

◆ addTempRoot()

void nix::RemoteStore::addTempRoot ( const StorePath & path)
overridevirtual

Add a store path as a temporary root of the garbage collector. The root disappears as soon as we exit.

Reimplemented from nix::Store.

◆ addToStore()

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

Import a path into the store.

Implements nix::Store.

◆ addToStoreFromDump()

StorePath nix::RemoteStore::addToStoreFromDump ( Source & dump,
std::string_view name,
FileSerialisationMethod dumpMethod = FileSerialisationMethod::NixArchive,
ContentAddressMethod hashMethod = FileIngestionMethod::NixArchive,
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
const StorePathSet & references = StorePathSet(),
RepairFlag repair = NoRepair )
overridevirtual

Add a content-addressable store path. dump will be drained.

Implements nix::Store.

◆ buildDerivation()

BuildResult nix::RemoteStore::buildDerivation ( const StorePath & drvPath,
const BasicDerivation & drv,
BuildMode buildMode )
overridevirtual

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 from nix::Store.

◆ buildPaths()

void nix::RemoteStore::buildPaths ( const std::vector< DerivedPath > & paths,
BuildMode buildMode,
std::shared_ptr< Store > evalStore )
overridevirtual

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 from nix::Store.

◆ buildPathsWithResults()

std::vector< KeyedBuildResult > nix::RemoteStore::buildPathsWithResults ( const std::vector< DerivedPath > & paths,
BuildMode buildMode,
std::shared_ptr< Store > evalStore )
overridevirtual

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 from nix::Store.

◆ collectGarbage()

void nix::RemoteStore::collectGarbage ( const GCOptions & options,
GCResults & results )
overridevirtual

Perform a garbage collection.

Implements nix::GcStore.

◆ connect()

void nix::RemoteStore::connect ( )
overridevirtual

Establish a connection to the store, for store types that have a notion of connection. Otherwise this is a no-op.

Reimplemented from nix::Store.

◆ ensurePath()

void nix::RemoteStore::ensurePath ( const StorePath & path)
overridevirtual

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 from nix::Store.

◆ findRoots()

Roots nix::RemoteStore::findRoots ( bool censor)
overridevirtual

Find the roots of the garbage collector. Each root is a pair (link, storepath) where link is the path of the symlink outside of the Nix store that point to storePath. If censor is true, privacy-sensitive information about roots found in /proc is censored.

Implements nix::GcStore.

◆ getFSAccessor()

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

Implements nix::Store.

Reimplemented in nix::MountedSSHStore, and nix::UDSRemoteStore.

◆ getProtocol()

unsigned int nix::RemoteStore::getProtocol ( )
overridevirtual

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

Reimplemented from nix::Store.

◆ getVersion()

std::optional< std::string > nix::RemoteStore::getVersion ( )
overridevirtual

Reimplemented from nix::Store.

◆ isTrustedClient()

std::optional< TrustedFlag > nix::RemoteStore::isTrustedClient ( )
overridevirtual
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.

Implements nix::Store.

◆ isValidPathUncached()

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

Reimplemented from nix::Store.

◆ narFromPath()

void nix::RemoteStore::narFromPath ( const StorePath & path,
Sink & sink )
overrideprotectedvirtual

Write a NAR dump of a store path.

Implements nix::Store.

Reimplemented in nix::MountedSSHStore, and nix::UDSRemoteStore.

◆ optimiseStore()

void nix::RemoteStore::optimiseStore ( )
overridevirtual

Optimise the disk space usage of the Nix store by hard-linking files with the same contents.

Reimplemented from nix::Store.

◆ queryAllValidPaths()

StorePathSet nix::RemoteStore::queryAllValidPaths ( )
overridevirtual

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 from nix::Store.

◆ queryDerivationOutputs()

StorePathSet nix::RemoteStore::queryDerivationOutputs ( const StorePath & path)
overridevirtual

Query the outputs of the derivation denoted by path.

Reimplemented from nix::Store.

◆ queryMissing()

void nix::RemoteStore::queryMissing ( const std::vector< DerivedPath > & targets,
StorePathSet & willBuild,
StorePathSet & willSubstitute,
StorePathSet & unknown,
uint64_t & downloadSize,
uint64_t & narSize )
overridevirtual

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 from nix::Store.

◆ queryPartialDerivationOutputMap()

std::map< std::string, std::optional< StorePath > > nix::RemoteStore::queryPartialDerivationOutputMap ( const StorePath & path,
Store * evalStore = nullptr )
overridevirtual

Query the mapping outputName => outputPath for the given derivation. All outputs are mentioned so ones mising the mapping are mapped to std::nullopt.

Reimplemented from nix::Store.

◆ queryPathFromHashPart()

std::optional< StorePath > nix::RemoteStore::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::RemoteStore::queryPathInfoUncached ( const StorePath & path,
Callback< std::shared_ptr< const ValidPathInfo > > callback )
overridevirtualnoexcept

Implements nix::Store.

◆ queryRealisationUncached()

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

Implements nix::Store.

◆ queryReferrers()

void nix::RemoteStore::queryReferrers ( const StorePath & path,
StorePathSet & referrers )
overridevirtual

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

Reimplemented from nix::Store.

◆ querySubstitutablePathInfos()

void nix::RemoteStore::querySubstitutablePathInfos ( const StorePathCAMap & paths,
SubstitutablePathInfos & infos )
overridevirtual

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 from nix::Store.

◆ querySubstitutablePaths()

StorePathSet nix::RemoteStore::querySubstitutablePaths ( const StorePathSet & paths)
overridevirtual

Query which of the given paths have substitutes.

Reimplemented from nix::Store.

◆ queryValidDerivers()

StorePathSet nix::RemoteStore::queryValidDerivers ( const StorePath & path)
overridevirtual
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 from nix::Store.

◆ queryValidPaths()

StorePathSet nix::RemoteStore::queryValidPaths ( const StorePathSet & paths,
SubstituteFlag maybeSubstitute = NoSubstitute )
overridevirtual

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

Reimplemented from nix::Store.

◆ registerDrvOutput()

void nix::RemoteStore::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.

◆ repairPath()

void nix::RemoteStore::repairPath ( const StorePath & path)
inlineoverridevirtual

The default instance would schedule the work on the client side, but for consistency with buildPaths and buildDerivation it should happen on the remote side.

We make this fail for now so we can add implement this properly later without it being a breaking change.

Reimplemented from nix::Store.

◆ setOptions()

void nix::RemoteStore::setOptions ( )
overrideprotectedvirtual

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

Reimplemented from nix::Store.

◆ verifyStore()

bool nix::RemoteStore::verifyStore ( bool checkContents,
RepairFlag repair )
overridevirtual

Check the integrity of the Nix store.

Returns
true if errors remain.

Reimplemented from nix::Store.


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