Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::RestrictedStore Struct Reference
Inheritance diagram for nix::RestrictedStore:
nix::IndirectRootStore nix::GcStore nix::SubmitStore nix::LocalFSStore nix::Store nix::Store nix::Store nix::GcStore nix::LogStore nix::StoreDirConfig nix::StoreDirConfig nix::StoreDirConfig nix::Store nix::Store nix::StoreDirConfig nix::StoreDirConfig

Public Member Functions

 RestrictedStore (ref< LocalStore::Config > config, ref< LocalStore > next, RestrictionContext &goal)
std::filesystem::path getRealStoreDir () 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
std::map< std::string, std::optional< StorePath > > queryPartialDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr) override
std::optional< StorePath > queryPathFromHashPart (const std::string &hashPart) override
StorePath addToStore (std::string_view name, const SourcePath &srcPath, ContentAddressMethod method, HashAlgorithm hashAlgo, const StorePathSet &references, PathFilter &filter, RepairFlag repair) override
void addToStore (const ValidPathInfo &info, Source &narSource, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs) override
StorePath addToStoreFromDump (Source &dump, std::string_view name, FileSerialisationMethod dumpMethod, ContentAddressMethod hashMethod, HashAlgorithm hashAlgo, const StorePathSet &references, RepairFlag repair) override
void narFromPath (const StorePath &path, Sink &sink) override
void registerDrvOutputUnchecked (const Realisation &info) override
void submitOutput (const SingleDerivedPath &path, const OutputName &output) override
ref< const ValidPathInfo > addToStoreScanning (Source &dump, std::string_view name, FileSerialisationMethod dumpMethod, ContentAddressMethod hashMethod, HashAlgorithm hashAlgo) override
void queryRealisationUncached (const DrvOutput &id, Callback< std::shared_ptr< const UnkeyedRealisation > > callback) noexcept override
void addTempRoots (const StorePathSet &paths) override
void addIndirectRoot (const std::filesystem::path &path) override
Roots findRoots (bool censor) override
void collectGarbage (const GCOptions &options, GCResults &results) override
void deleteBuildTraces (const std::set< DrvOutput > &keys) override
void addSignatures (const StorePath &storePath, const std::set< Signature > &sigs) override
MissingPaths queryMissing (const std::vector< DerivedPath > &targets) override
virtual std::optional< std::string > getBuildLogExact (const StorePath &path) override
virtual void addBuildLog (const StorePath &path, std::string_view log) override
std::optional< TrustedFlag > isTrustedClient () override
ref< Builder > getBuilder (std::shared_ptr< Store > evalStore) override
Public Member Functions inherited from nix::IndirectRootStore
std::filesystem::path addPermRoot (const StorePath &storePath, const std::filesystem::path &gcRoot) override final
Public Member Functions inherited from nix::LocalFSStore
 LocalFSStore (const Config &params)
ref< SourceAccessor > getFSAccessor (bool requireValidPath=true) override
std::shared_ptr< SourceAccessor > getFSAccessor (const StorePath &path, bool requireValidPath=true) override
std::filesystem::path toRealPath (const StorePath &storePath)
Public Member Functions inherited from nix::Store
 operator const Config & () const
virtual void init ()
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)
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 StorePathSet queryValidDerivers (const StorePath &path)
virtual StorePathSet queryDerivationOutputs (const StorePath &path)
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 StorePathSet querySubstitutablePaths (const StorePathSet &paths)
virtual void querySubstitutablePathInfos (const StorePathCAMap &paths, SubstitutablePathInfos &infos)
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, CheckSigsFlag checkSigs)
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)
ref< SourceAccessor > requireStoreObjectAccessor (const StorePath &path, bool requireValidPath=true)
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 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 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 Member Functions inherited from nix::LogStore
std::optional< std::string > getBuildLog (const StorePath &path)

Public Attributes

ref< const LocalStore::Config > config
ref< LocalStore > next
RestrictionContext & goal
Public Attributes inherited from nix::LocalFSStore
const Config & config
Public Attributes inherited from nix::Store
const Config & config
Public Attributes inherited from nix::StoreDirConfig
const std::string & storeDir

Additional Inherited Members

Public Types inherited from nix::LocalFSStore
using Config = LocalFSStoreConfig
Public Types inherited from nix::Store
using Config = StoreConfig
using PathsSource = std::vector<std::pair<ValidPathInfo, std::unique_ptr<Source>>>
Static Public Member Functions inherited from nix::SubmitStore
static SubmitStore & require (Store &store)
Static Public Attributes inherited from nix::IndirectRootStore
static std::string operationName = "Indirect GC roots registration"
Static Public Attributes inherited from nix::LocalFSStore
static std::string operationName = "Local Filesystem Store"
static const std::filesystem::path drvsLogDir = "drvs"
Static Public Attributes inherited from nix::Store
static constexpr const char * MissingName = "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"
Static Public Attributes inherited from nix::SubmitStore
static std::string operationName = "Submit outputs for a currently running derivation"
Protected Member Functions inherited from nix::IndirectRootStore
void makeSymlink (const std::filesystem::path &link, const std::filesystem::path &target)
Protected Member Functions inherited from nix::Store
void invalidatePathInfoCacheFor (const StorePath &path)
 Store (const Store::Config &config)
virtual bool isValidPathUncached (const StorePath &path)
void unsupported (const std::string &op)
Protected Attributes inherited from nix::Store
std::shared_ptr< SharedSync< LRUCache< StorePath, PathInfoCacheValue > > > pathInfoCache
std::shared_ptr< NarInfoDiskCache > diskCache

Detailed Description

A wrapper around LocalStore that only allows building/querying of paths that are in the input closures of the build or were added via recursive Nix calls.

Member Function Documentation

◆ addBuildLog()

virtual void nix::RestrictedStore::addBuildLog ( const StorePath & path,
std::string_view log )
inlineoverridevirtual

Implements nix::LogStore.

◆ addIndirectRoot()

void nix::RestrictedStore::addIndirectRoot ( const std::filesystem::path & path)
inlineoverridevirtual

Add an indirect root, which is a weak reference to the user-facing symlink created by addPermRoot().

Parameters
pathuser-facing and user-controlled symlink to a store path.

The form this weak-reference takes is implementation-specific.

Implements nix::IndirectRootStore.

◆ addSignatures()

void nix::RestrictedStore::addSignatures ( const StorePath & storePath,
const std::set< Signature > & sigs )
inlineoverridevirtual

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

Reimplemented from nix::Store.

◆ addTempRoots()

void nix::RestrictedStore::addTempRoots ( const StorePathSet & paths)
inlineoverridevirtual

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

◆ addToStore() [1/2]

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

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.

Implements nix::Store.

◆ addToStore() [2/2]

StorePath nix::RestrictedStore::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()

StorePath nix::RestrictedStore::addToStoreFromDump ( Source & dump,
std::string_view name,
FileSerialisationMethod dumpMethod,
ContentAddressMethod hashMethod,
HashAlgorithm hashAlgo,
const StorePathSet & references,
RepairFlag repair )
overridevirtual

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.

◆ addToStoreScanning()

ref< const ValidPathInfo > nix::RestrictedStore::addToStoreScanning ( Source & dump,
std::string_view name,
FileSerialisationMethod dumpMethod,
ContentAddressMethod hashMethod,
HashAlgorithm hashAlgo )
overridevirtual

Add to store, scanning references. Only within a recursive-nix derivation, as there would otherwise be no known set of valid store paths

Implements nix::SubmitStore.

◆ collectGarbage()

void nix::RestrictedStore::collectGarbage ( const GCOptions & options,
GCResults & results )
inlineoverridevirtual

Perform a garbage collection.

Implements nix::GcStore.

◆ deleteBuildTraces()

void nix::RestrictedStore::deleteBuildTraces ( const std::set< DrvOutput > & keys)
inlineoverridevirtual

Delete build trace entries (realisations) from the store's database.

The entries are specified by their key (the build trace is a map).

Implements nix::GcStore.

◆ findRoots()

Roots nix::RestrictedStore::findRoots ( bool censor)
inlineoverridevirtual

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.

◆ getBuilder()

ref< Builder > nix::RestrictedStore::getBuilder ( std::shared_ptr< Store > evalStore)
inlineoverridevirtual

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

◆ getBuildLogExact()

virtual std::optional< std::string > nix::RestrictedStore::getBuildLogExact ( const StorePath & path)
inlineoverridevirtual

Reimplemented from nix::LocalFSStore.

◆ getRealStoreDir()

std::filesystem::path nix::RestrictedStore::getRealStoreDir ( )
inlineoverridevirtual

Reimplemented from nix::LocalFSStore.

◆ isTrustedClient()

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

◆ narFromPath()

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

Write a NAR dump of a store path.

Reimplemented from nix::Store.

◆ queryAllValidPaths()

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

◆ queryMissing()

MissingPaths nix::RestrictedStore::queryMissing ( const std::vector< DerivedPath > & targets)
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::RestrictedStore::queryPartialDerivationOutputMap ( const StorePath & path,
Store * evalStore = nullptr )
overridevirtual

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

Reimplemented from nix::Store.

◆ queryPathFromHashPart()

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

Implements nix::Store.

◆ queryRealisationUncached()

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

Implements nix::Store.

◆ queryReferrers()

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

◆ registerDrvOutputUnchecked()

void nix::RestrictedStore::registerDrvOutputUnchecked ( 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.

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

Implements nix::Store.

◆ submitOutput()

void nix::RestrictedStore::submitOutput ( const SingleDerivedPath & path,
const OutputName & output )
overridevirtual

Submit an output for the current derivation. Only makes sense when running within a recursive-nix derivation

Implements nix::SubmitStore.


The documentation for this struct was generated from the following file:
  • libstore/restricted-store.cc