Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
nix::LegacySSHStore Struct Reference
Inheritance diagram for nix::LegacySSHStore:
nix::LegacySSHStoreConfig nix::Store nix::CommonSSHStoreConfig nix::StoreConfig nix::StoreConfig nix::StoreDirConfig nix::StoreDirConfig nix::Config nix::Config nix::AbstractConfig nix::AbstractConfig

Classes

struct  Connection
 
struct  ConnectionStats
 

Public Member Functions

 LegacySSHStore (std::string_view scheme, std::string_view host, const Params &params)
 
ref< ConnectionopenConnection ()
 
std::string getUri () override
 
void queryPathInfoUncached (const StorePath &path, Callback< std::shared_ptr< const ValidPathInfo > > callback) noexcept override
 
std::map< StorePath, UnkeyedValidPathInfoqueryPathInfosUncached (const StorePathSet &paths)
 
void addToStore (const ValidPathInfo &info, Source &source, RepairFlag repair, CheckSigsFlag checkSigs) override
 
void narFromPath (const StorePath &path, Sink &sink) override
 
void narFromPath (const StorePath &path, std::function< void(Source &)> fun)
 
std::optional< StorePathqueryPathFromHashPart (const std::string &hashPart) override
 
StorePath addToStore (std::string_view name, const SourcePath &path, ContentAddressMethod method, HashAlgorithm hashAlgo, const StorePathSet &references, PathFilter &filter, RepairFlag repair) override
 
virtual 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
 
BuildResult buildDerivation (const StorePath &drvPath, const BasicDerivation &drv, BuildMode buildMode) override
 
std::function< BuildResult()> buildDerivationAsync (const StorePath &drvPath, const BasicDerivation &drv, const ServeProto::BuildOptions &options)
 
void buildPaths (const std::vector< DerivedPath > &drvPaths, BuildMode buildMode, std::shared_ptr< Store > evalStore) override
 
void ensurePath (const StorePath &path) override
 
virtual ref< SourceAccessorgetFSAccessor (bool requireValidPath) override
 
void repairPath (const StorePath &path) override
 
void computeFSClosure (const StorePathSet &paths, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false) override
 
StorePathSet queryValidPaths (const StorePathSet &paths, SubstituteFlag maybeSubstitute=NoSubstitute) override
 
StorePathSet queryValidPaths (const StorePathSet &paths, bool lock, SubstituteFlag maybeSubstitute=NoSubstitute)
 
void addMultipleToStoreLegacy (Store &srcStore, const StorePathSet &paths)
 
void connect () override
 
unsigned int getProtocol () override
 
ConnectionStats getConnectionStats ()
 
pid_t getConnectionPid ()
 
std::optional< TrustedFlag > isTrustedClient () override
 
void queryRealisationUncached (const DrvOutput &, Callback< std::shared_ptr< const Realisation > > callback) noexcept override
 
- Public Member Functions inherited from nix::LegacySSHStoreConfig
 LegacySSHStoreConfig (std::string_view scheme, std::string_view authority, const Params &params)
 
const std::string name () override
 
std::string doc () override
 
 CommonSSHStoreConfig (std::string_view scheme, std::string_view host, const Params &params)
 
- Public Member Functions inherited from nix::CommonSSHStoreConfig
 CommonSSHStoreConfig (std::string_view scheme, std::string_view host, const Params &params)
 
SSHMaster createSSHMaster (bool useMaster, Descriptor logFD=INVALID_DESCRIPTOR)
 
 StoreConfig ()=delete
 
- Public Member Functions inherited from nix::StoreConfig
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 ()
 
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 queryAllValidPaths ()
 
ref< const ValidPathInfoqueryPathInfo (const StorePath &path)
 
void queryPathInfo (const StorePath &path, Callback< ref< const ValidPathInfo > > callback) noexcept
 
std::optional< std::shared_ptr< const ValidPathInfo > > queryPathInfoFromClientCache (const StorePath &path)
 
std::shared_ptr< const RealisationqueryRealisation (const DrvOutput &)
 
void queryRealisation (const DrvOutput &, Callback< std::shared_ptr< const Realisation > > callback) noexcept
 
virtual bool pathInfoIsUntrusted (const ValidPathInfo &)
 
virtual bool realisationIsUntrusted (const Realisation &)
 
virtual void queryReferrers (const StorePath &path, StorePathSet &referrers)
 
virtual StorePathSet queryValidDerivers (const StorePath &path)
 
virtual StorePathSet queryDerivationOutputs (const StorePath &path)
 
virtual std::map< std::string, std::optional< StorePath > > queryPartialDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
 
virtual std::map< std::string, std::optional< StorePath > > queryStaticPartialDerivationOutputMap (const StorePath &path)
 
OutputPathMap queryDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
 
virtual StorePathSet querySubstitutablePaths (const StorePathSet &paths)
 
virtual void querySubstitutablePathInfos (const StorePathCAMap &paths, SubstitutablePathInfos &infos)
 
virtual void addMultipleToStore (Source &source, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs)
 
virtual void addMultipleToStore (PathsSource &&pathsToCopy, Activity &act, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs)
 
ValidPathInfo addToStoreSlow (std::string_view name, const SourcePath &path, ContentAddressMethod method=ContentAddressMethod::Raw::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references=StorePathSet(), std::optional< Hash > expectedCAHash={})
 
virtual void registerDrvOutput (const Realisation &output)
 
virtual void registerDrvOutput (const Realisation &output, CheckSigsFlag checkSigs)
 
virtual std::vector< KeyedBuildResultbuildPathsWithResults (const std::vector< DerivedPath > &paths, BuildMode buildMode=bmNormal, std::shared_ptr< Store > evalStore=nullptr)
 
virtual void addTempRoot (const StorePath &path)
 
std::string makeValidityRegistration (const StorePathSet &paths, bool showDerivers, bool showHash)
 
virtual void optimiseStore ()
 
virtual bool verifyStore (bool checkContents, RepairFlag repair=NoRepair)
 
virtual void addSignatures (const StorePath &storePath, const StringSet &sigs)
 
Derivation derivationFromPath (const StorePath &drvPath)
 
Derivation readDerivation (const StorePath &drvPath)
 
Derivation readInvalidDerivation (const StorePath &drvPath)
 
void computeFSClosure (const StorePath &path, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false)
 
virtual void queryMissing (const std::vector< DerivedPath > &targets, StorePathSet &willBuild, StorePathSet &willSubstitute, StorePathSet &unknown, uint64_t &downloadSize, uint64_t &narSize)
 
StorePaths topoSortPaths (const StorePathSet &paths)
 
void exportPaths (const StorePathSet &paths, Sink &sink)
 
void exportPath (const StorePath &path, Sink &sink)
 
StorePaths importPaths (Source &source, CheckSigsFlag checkSigs=CheckSigs)
 
const StatsgetStats ()
 
StorePathSet exportReferences (const StorePathSet &storePaths, const StorePathSet &inputPaths)
 
std::optional< StorePathgetBuildDerivationPath (const StorePath &)
 
void clearPathInfoCache ()
 
virtual Path toRealPath (const Path &storePath)
 
Path toRealPath (const StorePath &storePath)
 
virtual void setOptions ()
 
virtual std::optional< std::string > getVersion ()
 

Public Attributes

const Setting< intlogFD {this, INVALID_DESCRIPTOR, "log-fd", "file descriptor to which SSH's stderr is connected"}
 
ref< Pool< Connection > > connections
 
SSHMaster master
 
- Public Attributes inherited from nix::LegacySSHStoreConfig
const Setting< Strings > remoteProgram
 
const Setting< intmaxConnections
 
Strings extraSshArgs = {}
 
std::optional< size_tconnPipeSize
 
- Public Attributes inherited from nix::CommonSSHStoreConfig
const Setting< PathsshKey
 
const Setting< std::string > sshPublicHostKey
 
const Setting< bool > compress
 
const Setting< std::string > remoteStore
 
std::string host
 
- 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_
 

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::LegacySSHStoreConfig
static std::set< std::string > uriSchemes ()
 
- Static Public Member Functions inherited from nix::StoreConfig
static StringSet getDefaultSystemFeatures ()
 
- Static Public Attributes inherited from nix::Store
static constexpr const charMissingName = "x"
 
- Protected Member Functions inherited from nix::AbstractConfig
 AbstractConfig (StringMap initials={})
 
- Protected Member Functions inherited from nix::Store
 Store (const Params &params)
 
virtual bool isValidPathUncached (const StorePath &path)
 
void unsupported (const std::string &op)
 
- Protected Attributes inherited from nix::AbstractConfig
StringMap unknownSettings
 
- Protected Attributes inherited from nix::Store
SharedSync< Statestate
 
std::shared_ptr< NarInfoDiskCachediskCache
 
Stats stats
 

Member Function Documentation

◆ addMultipleToStoreLegacy()

void nix::LegacySSHStore::addMultipleToStoreLegacy ( Store & srcStore,
const StorePathSet & paths )

Just exists because this is exactly what Hydra was doing, and we don't yet want an algorithmic change.

◆ addToStore() [1/2]

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

Import a path into the store.

Implements nix::Store.

◆ addToStore() [2/2]

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

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

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

Reimplemented from nix::Store.

◆ addToStoreFromDump()

virtual StorePath nix::LegacySSHStore::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 )
inlineoverridevirtual

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

dump may be drained.

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

Implements nix::Store.

◆ buildDerivation()

BuildResult nix::LegacySSHStore::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.

◆ buildDerivationAsync()

std::function< BuildResult()> nix::LegacySSHStore::buildDerivationAsync ( const StorePath & drvPath,
const BasicDerivation & drv,
const ServeProto::BuildOptions & options )

Note, the returned function must only be called once, or we'll try to read from the connection twice.

Todo
Use C++23 std::move_only_function.

◆ buildPaths()

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

◆ computeFSClosure()

void nix::LegacySSHStore::computeFSClosure ( const StorePathSet & paths,
StorePathSet & out,
bool flipDirection = false,
bool includeOutputs = false,
bool includeDerivers = false )
overridevirtual
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 from nix::Store.

◆ connect()

void nix::LegacySSHStore::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::LegacySSHStore::ensurePath ( const StorePath & path)
inlineoverridevirtual

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.

◆ getFSAccessor()

virtual ref< SourceAccessor > nix::LegacySSHStore::getFSAccessor ( bool requireValidPath)
inlineoverridevirtual
Returns
An object to access files in the Nix store.

Implements nix::Store.

◆ getProtocol()

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

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

Reimplemented from nix::Store.

◆ getUri()

std::string nix::LegacySSHStore::getUri ( )
overridevirtual
Todo
move to StoreConfig one we store enough information in those to recover the scheme and authority in all cases.

Implements nix::Store.

◆ isTrustedClient()

std::optional< TrustedFlag > nix::LegacySSHStore::isTrustedClient ( )
inlineoverridevirtual

The legacy ssh protocol doesn't support checking for trusted-user. Try using ssh-ng:// instead if you want to know.

Implements nix::Store.

◆ narFromPath() [1/2]

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

Write a NAR dump of a store path.

Implements nix::Store.

◆ narFromPath() [2/2]

void nix::LegacySSHStore::narFromPath ( const StorePath & path,
std::function< void(Source &)> fun )

Hands over the connection temporarily as source to the given function. The function must not consume beyond the NAR; it can not just blindly try to always read more bytes until it is cut-off.

This is exposed for sake of Hydra.

◆ queryPathFromHashPart()

std::optional< StorePath > nix::LegacySSHStore::queryPathFromHashPart ( const std::string & hashPart)
inlineoverridevirtual

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

Implements nix::Store.

◆ queryRealisationUncached()

void nix::LegacySSHStore::queryRealisationUncached ( const DrvOutput & ,
Callback< std::shared_ptr< const Realisation > > callback )
inlineoverridevirtualnoexcept

Implements nix::Store.

◆ queryValidPaths() [1/2]

StorePathSet nix::LegacySSHStore::queryValidPaths ( const StorePathSet & paths,
bool lock,
SubstituteFlag maybeSubstitute = NoSubstitute )

Custom variation that atomically creates temp locks on the remote side.

This exists to prevent a race where the remote host garbage-collects paths that are already there. Optionally, ask the remote host to substitute missing paths.

◆ queryValidPaths() [2/2]

StorePathSet nix::LegacySSHStore::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.

◆ repairPath()

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


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