Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::LocalStore Class Reference
Inheritance diagram for nix::LocalStore:
nix::IndirectRootStore nix::GcStore nix::LocalFSStore nix::Store nix::Store nix::GcStore nix::LogStore nix::Store nix::Store

Public Member Functions

LocalStoreConfigconfig () override
const LocalStoreConfigconfig () const override
std::optional< AssociatedCredentialsassociatedCredentials () const override
void associateWithCredentials (uid_t user, gid_t group)
std::string getUri () override
kj::Promise< Result< bool > > isValidPathUncached (const StorePath &path) override
kj::Promise< Result< StorePathSet > > queryValidPaths (const StorePathSet &paths, SubstituteFlag maybeSubstitute=NoSubstitute) override
kj::Promise< Result< StorePathSet > > queryAllValidPaths () override
kj::Promise< Result< std::shared_ptr< const ValidPathInfo > > > queryPathInfoUncached (const StorePath &path) override
kj::Promise< Result< void > > queryReferrers (const StorePath &path, StorePathSet &referrers) override
kj::Promise< Result< StorePathSet > > queryValidDerivers (const StorePath &path) override
kj::Promise< Result< std::map< std::string, std::optional< StorePath > > > > queryStaticPartialDerivationOutputMap (const StorePath &path) override
kj::Promise< Result< std::optional< StorePath > > > queryPathFromHashPart (const std::string &hashPart) override
kj::Promise< Result< StorePathSet > > querySubstitutablePaths (const StorePathSet &paths) override
bool pathInfoIsUntrusted (const ValidPathInfo &) override
bool realisationIsUntrusted (const Realisation &) override
kj::Promise< Result< void > > addToStore (const ValidPathInfo &info, AsyncInputStream &source, RepairFlag repair, CheckSigsFlag checkSigs) override
kj::Promise< Result< StorePath > > addToStoreFromDump (AsyncInputStream &dump, std::string_view name, FileIngestionMethod method, HashType hashAlgo, RepairFlag repair, const StorePathSet &references) override
kj::Promise< Result< StorePath > > addTextToStore (std::string_view name, std::string_view s, const StorePathSet &references, RepairFlag repair) override
kj::Promise< Result< void > > addTempRoot (const StorePath &path) override
kj::Promise< Result< void > > addIndirectRoot (const Path &path) override
kj::Promise< Result< Roots > > findRoots (bool censor) override
kj::Promise< Result< void > > collectGarbage (const GCOptions &options, GCResults &results) override
kj::Promise< Result< void > > optimiseStore (OptimiseStats &stats)
kj::Promise< Result< void > > optimiseStore () override
void optimisePath (const Path &path, RepairFlag repair)
kj::Promise< Result< bool > > verifyStore (bool checkContents, RepairFlag repair) override
kj::Promise< Result< void > > registerValidPath (const ValidPathInfo &info)
kj::Promise< Result< void > > registerValidPaths (const ValidPathInfos &infos)
kj::Promise< Result< unsigned int > > getProtocol () override
kj::Promise< Result< std::optional< TrustedFlag > > > isTrustedClient () override
kj::Promise< Result< void > > addSignatures (const StorePath &storePath, const StringSet &sigs) override
kj::Promise< Result< void > > autoGC (bool sync=true)
kj::Promise< Result< void > > registerDrvOutput (const Realisation &info) override
kj::Promise< Result< void > > registerDrvOutput (const Realisation &info, CheckSigsFlag checkSigs) override
void cacheDrvOutputMapping (DBState &state, const uint64_t deriver, const std::string &outputName, const StorePath &output)
std::optional< const RealisationqueryRealisation_ (DBState &state, const DrvOutput &id)
std::optional< std::pair< int64_t, Realisation > > queryRealisationCore_ (DBState &state, const DrvOutput &id)
kj::Promise< Result< std::shared_ptr< const Realisation > > > queryRealisationUncached (const DrvOutput &) override
kj::Promise< Result< std::optional< std::string > > > getVersion () override
Public Member Functions inherited from nix::IndirectRootStore
kj::Promise< Result< Path > > addPermRoot (const StorePath &storePath, const Path &gcRoot) override final
Public Member Functions inherited from nix::LocalFSStore
kj::Promise< Result< box_ptr< Source > > > narFromPath (const StorePath &path) override
ref< FSAccessorgetFSAccessor () override
virtual Path getRealStoreDir ()
Path toRealPath (const Path &storePath) override
kj::Promise< Result< std::optional< std::string > > > getBuildLogExact (const StorePath &path) override
Public Member Functions inherited from nix::Store
virtual kj::Promise< Result< void > > init ()
StorePath parseStorePath (std::string_view path) const
std::optional< StorePathmaybeParseStorePath (std::string_view path) const
std::string printStorePath (const StorePath &path) const
StorePathSet parseStorePathSet (const PathSet &paths) const
PathSet printStorePathSet (const StorePathSet &path) const
std::string showPaths (const StorePathSet &paths)
bool isInStore (PathView path) const
bool isStorePath (std::string_view path) const
std::pair< StorePath, PathtoStorePath (PathView path) const
Path followLinksToStore (std::string_view path) const
StorePath followLinksToStorePath (std::string_view path) const
StorePath makeStorePath (std::string_view type, std::string_view hash, std::string_view name) const
StorePath makeStorePath (std::string_view type, const Hash &hash, std::string_view name) const
StorePath makeOutputPath (std::string_view id, const Hash &hash, std::string_view name) const
StorePath makeFixedOutputPath (std::string_view name, const FixedOutputInfo &info) const
StorePath makeTextPath (std::string_view name, const TextInfo &info) const
StorePath makeFixedOutputPathFromCA (std::string_view name, const ContentAddressWithReferences &ca) const
StorePath computeStorePathForPathRecursive (std::string_view name, const PreparedDump &source) const
StorePath computeStorePathForPathFlat (std::string_view name, const Path &srcPath) const
StorePath computeStorePathForText (std::string_view name, std::string_view s, const StorePathSet &references) const
kj::Promise< Result< bool > > isValidPath (const StorePath &path)
kj::Promise< Result< void > > substitutePaths (const StorePathSet &paths)
kj::Promise< Result< ref< const ValidPathInfo > > > queryPathInfo (const StorePath &path)
kj::Promise< Result< std::shared_ptr< const Realisation > > > queryRealisation (const DrvOutput &)
virtual kj::Promise< Result< StorePathSet > > queryDerivationOutputs (const StorePath &path)
virtual kj::Promise< Result< std::map< std::string, std::optional< StorePath > > > > queryPartialDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
kj::Promise< Result< OutputPathMap > > queryDerivationOutputMap (const StorePath &path, Store *evalStore=nullptr)
virtual kj::Promise< Result< void > > querySubstitutablePathInfos (const StorePathCAMap &paths, SubstitutablePathInfos &infos)
virtual kj::Promise< Result< void > > addMultipleToStore (PathsSource &pathsToCopy, Activity &act, RepairFlag repair=NoRepair, CheckSigsFlag checkSigs=CheckSigs)
virtual kj::Promise< Result< StorePath > > addToStoreRecursive (std::string_view name, const PreparedDump &source, HashType hashAlgo=HashType::SHA256, RepairFlag repair=NoRepair)
virtual kj::Promise< Result< StorePath > > addToStoreFlat (std::string_view name, const Path &srcPath, HashType hashAlgo=HashType::SHA256, RepairFlag repair=NoRepair)
kj::Promise< Result< ValidPathInfo > > addToStoreSlow (std::string_view name, const Path &srcPath, FileIngestionMethod method=FileIngestionMethod::Recursive, HashType hashAlgo=HashType::SHA256, std::optional< Hash > expectedCAHash={})
virtual kj::Promise< Result< void > > buildPaths (const std::vector< DerivedPath > &paths, BuildMode buildMode=bmNormal, std::shared_ptr< Store > evalStore=nullptr)
virtual kj::Promise< Result< std::vector< KeyedBuildResult > > > buildPathsWithResults (const std::vector< DerivedPath > &paths, BuildMode buildMode=bmNormal, std::shared_ptr< Store > evalStore=nullptr)
virtual kj::Promise< Result< BuildResult > > buildDerivation (const StorePath &drvPath, const BasicDerivation &drv, BuildMode buildMode=bmNormal)
virtual kj::Promise< Result< void > > ensurePath (const StorePath &path)
kj::Promise< Result< std::string > > makeValidityRegistration (const StorePathSet &paths, bool showDerivers, bool showHash)
kj::Promise< Result< JSON > > pathInfoToJSON (const StorePathSet &storePaths, bool includeImpureInfo, bool showClosureSize, Base hashBase=Base::Base32, AllowInvalidFlag allowInvalid=DisallowInvalid)
kj::Promise< Result< std::pair< uint64_t, uint64_t > > > getClosureSize (const StorePath &storePath)
virtual kj::Promise< Result< void > > repairPath (const StorePath &path)
kj::Promise< Result< Derivation > > derivationFromPath (const StorePath &drvPath)
kj::Promise< Result< Derivation > > readDerivation (const StorePath &drvPath)
kj::Promise< Result< Derivation > > readInvalidDerivation (const StorePath &drvPath)
virtual kj::Promise< Result< void > > computeFSClosure (const StorePathSet &paths, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false)
kj::Promise< Result< void > > computeFSClosure (const StorePath &path, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false)
virtual kj::Promise< Result< void > > queryMissing (const std::vector< DerivedPath > &targets, StorePathSet &willBuild, StorePathSet &willSubstitute, StorePathSet &unknown, uint64_t &downloadSize, uint64_t &narSize)
kj::Promise< Result< StorePaths > > topoSortPaths (const StorePathSet &paths)
kj::Promise< Result< void > > exportPaths (const StorePathSet &paths, Sink &sink)
kj::Promise< Result< void > > exportPath (const StorePath &path, Sink &sink)
kj::Promise< Result< StorePaths > > importPaths (Source &source, CheckSigsFlag checkSigs=CheckSigs)
kj::Promise< Result< Stats<> > > getStats ()
kj::Promise< Result< StorePathSet > > exportReferences (const StorePathSet &storePaths, const StorePathSet &inputPaths)
kj::Promise< Result< std::optional< StorePath > > > getBuildDerivationPath (const StorePath &)
kj::Promise< void > clearPathInfoCache ()
virtual kj::Promise< Result< void > > connect ()
Path toRealPath (const StorePath &storePath)
virtual kj::Promise< Result< void > > setOptions ()
Public Member Functions inherited from nix::LogStore
kj::Promise< Result< std::optional< std::string > > > getBuildLog (const StorePath &path)

Static Public Member Functions

static std::set< std::string > uriSchemes ()
static ref< LocalStoremakeLocalStore (const StoreConfig::Params &params)
Static Public Member Functions inherited from nix::LogStore
static LogStorerequire (Store &store)

Public Attributes

const Path dbDir
const Path linksDir
const Path reservedSpacePath
const Path schemaPath
const Path tempRootsDir
const Path fnTempRoots
PathSet locksHeld

Protected Member Functions

 LocalStore (LocalStoreConfig config)
 LocalStore (std::string scheme, std::string path, LocalStoreConfig config)
Protected Member Functions inherited from nix::Store
 Store (const StoreConfig &config)
void unsupported (const std::string &op)

Friends

struct LocalDerivationGoal
struct PathSubstitutionGoal
struct SubstitutionGoal
struct DerivationGoal

Additional Inherited Members

Public Types inherited from nix::Store
using PathsSource
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::string 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"
Protected Attributes inherited from nix::Store
Sync< State, AsyncMutex > state
std::shared_ptr< NarInfoDiskCachediskCache
Stats< std::atomic > stats

Constructor & Destructor Documentation

◆ LocalStore()

nix::LocalStore::LocalStore ( LocalStoreConfig config)
protected

Initialise the local store, upgrading the schema if necessary. Protected so that users don't accidentally create a LocalStore instead of a platform's subclass.

Member Function Documentation

◆ addIndirectRoot()

kj::Promise< Result< void > > nix::LocalStore::addIndirectRoot ( const Path & path)
overridevirtual

Implementation of IndirectRootStore::addIndirectRoot().

The weak reference merely is a symlink to path' from /nix/var/nix/gcroots/auto/<hash of path'>.

Implements nix::IndirectRootStore.

◆ addSignatures()

kj::Promise< Result< void > > nix::LocalStore::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()

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

◆ addTextToStore()

kj::Promise< Result< StorePath > > nix::LocalStore::addTextToStore ( std::string_view name,
std::string_view s,
const StorePathSet & references,
RepairFlag repair )
overridevirtual

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

Implements nix::Store.

◆ addToStore()

kj::Promise< Result< void > > nix::LocalStore::addToStore ( const ValidPathInfo & info,
AsyncInputStream & narSource,
RepairFlag repair,
CheckSigsFlag checkSigs )
overridevirtual

Import a path into the store.

Implements nix::Store.

◆ addToStoreFromDump()

kj::Promise< Result< StorePath > > nix::LocalStore::addToStoreFromDump ( AsyncInputStream & dump,
std::string_view name,
FileIngestionMethod method,
HashType hashAlgo,
RepairFlag repair,
const StorePathSet & references )
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

Todo
remove?

Reimplemented from nix::Store.

◆ associatedCredentials()

std::optional< AssociatedCredentials > nix::LocalStore::associatedCredentials ( ) const
inlineoverridevirtual

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

Reimplemented from nix::Store.

◆ autoGC()

kj::Promise< Result< void > > nix::LocalStore::autoGC ( bool sync = true)

If free disk space in /nix/store if below minFree, delete garbage until it exceeds maxFree.

◆ collectGarbage()

kj::Promise< Result< void > > nix::LocalStore::collectGarbage ( const GCOptions & options,
GCResults & results )
overridevirtual

Perform a garbage collection.

Implements nix::GcStore.

◆ config() [1/2]

const LocalStoreConfig & nix::LocalStore::config ( ) const
inlineoverridevirtual

Implements nix::LocalFSStore.

◆ config() [2/2]

LocalStoreConfig & nix::LocalStore::config ( )
inlineoverridevirtual

Implements nix::LocalFSStore.

◆ findRoots()

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

◆ getProtocol()

kj::Promise< Result< unsigned int > > nix::LocalStore::getProtocol ( )
overridevirtual

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

Reimplemented from nix::Store.

◆ getUri()

std::string nix::LocalStore::getUri ( )
overridevirtual

Implementations of abstract store API methods.

Implements nix::Store.

◆ getVersion()

kj::Promise< Result< std::optional< std::string > > > nix::LocalStore::getVersion ( )
overridevirtual

Reimplemented from nix::Store.

◆ isTrustedClient()

kj::Promise< Result< std::optional< TrustedFlag > > > nix::LocalStore::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()

kj::Promise< Result< bool > > nix::LocalStore::isValidPathUncached ( const StorePath & path)
overridevirtual

Reimplemented from nix::Store.

◆ makeLocalStore()

ref< LocalStore > nix::LocalStore::makeLocalStore ( const StoreConfig::Params & params)
static

Create a LocalStore, possibly a platform-specific subclass

◆ optimisePath()

void nix::LocalStore::optimisePath ( const Path & path,
RepairFlag repair )

Optimise a single store path. Optionally, test the encountered symlinks for corruption.

◆ optimiseStore() [1/2]

kj::Promise< Result< void > > nix::LocalStore::optimiseStore ( )
overridevirtual

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

Reimplemented from nix::Store.

◆ optimiseStore() [2/2]

kj::Promise< Result< void > > nix::LocalStore::optimiseStore ( OptimiseStats & stats)

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

◆ pathInfoIsUntrusted()

bool nix::LocalStore::pathInfoIsUntrusted ( const ValidPathInfo & )
overridevirtual

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

◆ queryAllValidPaths()

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

◆ queryPathFromHashPart()

kj::Promise< Result< std::optional< StorePath > > > nix::LocalStore::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()

kj::Promise< Result< std::shared_ptr< const ValidPathInfo > > > nix::LocalStore::queryPathInfoUncached ( const StorePath & path)
overridevirtual

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

Implements nix::Store.

◆ queryRealisationUncached()

kj::Promise< Result< std::shared_ptr< const Realisation > > > nix::LocalStore::queryRealisationUncached ( const DrvOutput & id)
overridevirtual

Implements nix::Store.

◆ queryReferrers()

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

◆ queryStaticPartialDerivationOutputMap()

kj::Promise< Result< std::map< std::string, std::optional< StorePath > > > > nix::LocalStore::queryStaticPartialDerivationOutputMap ( const StorePath & path)
overridevirtual

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

◆ querySubstitutablePaths()

kj::Promise< Result< StorePathSet > > nix::LocalStore::querySubstitutablePaths ( const StorePathSet & paths)
overridevirtual

Query which of the given paths have substitutes.

Reimplemented from nix::Store.

◆ queryValidDerivers()

kj::Promise< Result< StorePathSet > > nix::LocalStore::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()

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

◆ realisationIsUntrusted()

bool nix::LocalStore::realisationIsUntrusted ( const Realisation & realisation)
overridevirtual

Reimplemented from nix::Store.

◆ registerDrvOutput() [1/2]

kj::Promise< Result< void > > nix::LocalStore::registerDrvOutput ( const Realisation & info)
overridevirtual

Register the store path 'output' as the output named 'outputName' of derivation 'deriver'.

Reimplemented from nix::Store.

◆ registerDrvOutput() [2/2]

kj::Promise< Result< void > > nix::LocalStore::registerDrvOutput ( const Realisation & info,
CheckSigsFlag checkSigs )
overridevirtual

Reimplemented from nix::Store.

◆ registerValidPath()

kj::Promise< Result< void > > nix::LocalStore::registerValidPath ( const ValidPathInfo & info)

Register the validity of a path, i.e., that path exists, that the paths referenced by it exists, and in the case of an output path of a derivation, that it has been produced by a successful execution of the derivation (or something equivalent). Also register the hash of the file system contents of the path. The hash must be a SHA-256 hash.

◆ verifyStore()

kj::Promise< Result< bool > > nix::LocalStore::verifyStore ( bool checkContents,
RepairFlag repair )
overridevirtual

Check the integrity of the Nix store.

Returns
true if errors remain.

Reimplemented from nix::Store.

Member Data Documentation

◆ locksHeld

PathSet nix::LocalStore::locksHeld

Hack for build-remote.cc.

◆ reservedSpacePath

const Path nix::LocalStore::reservedSpacePath

Path kept around to reserve some filesystem space to be able to begin a garbage collection


The documentation for this class was generated from the following files:
  • lix/libstore/local-store.hh
  • lix/libstore/gc.cc
  • lix/libstore/local-store.cc
  • lix/libstore/optimise-store.cc
  • lix/libstore/platform.cc