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

#include <gc-store.hh>

Inheritance diagram for nix::GcStore:
nix::Store nix::StoreDirConfig nix::LocalFSStore nix::LocalStore nix::RemoteStore nix::RestrictedStore nix::IndirectRootStore nix::MountedSSHStore nix::LocalOverlayStore nix::SSHStore nix::UDSRemoteStore nix::LocalStore nix::RestrictedStore nix::UDSRemoteStore nix::MountedSSHStore nix::LocalOverlayStore

Public Member Functions

virtual Roots findRoots (bool censor)=0
virtual void collectGarbage (const GCOptions &options, GCResults &results)=0
virtual void deleteBuildTraces (const std::set< DrvOutput > &keys)=0
Public Member Functions inherited from nix::Store
 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

Static Public Attributes

static std::string operationName = "Garbage collection"
Static Public Attributes inherited from nix::Store
static constexpr const char * MissingName = "x"

Additional Inherited Members

Public Types inherited from nix::Store
using Config = StoreConfig
using PathsSource = std::vector<std::pair<ValidPathInfo, std::unique_ptr<Source>>>
Public Attributes inherited from nix::Store
const Config & config
Public Attributes inherited from nix::StoreDirConfig
const std::string & storeDir
Protected Member Functions inherited from nix::Store
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 inherited from nix::Store
std::shared_ptr< SharedSync< LRUCache< StorePath, PathInfoCacheValue > > > pathInfoCache
std::shared_ptr< NarInfoDiskCache > diskCache

Detailed Description

Mix-in class for stores which expose a notion of garbage collection.

Garbage collection will allow deleting paths which are not transitively "rooted".

The notion of GC roots actually not part of this class.

  • The base Store class has Store::addTempRoots() because for a store that doesn't support garbage collection at all, a temporary GC root is safely implementable as no-op.
Todo
actually this is not so good because stores are views. Some views have only a no-op temp roots even though others to the same store allow triggering GC. For instance one can't add a root over ssh, but that doesn't prevent someone from gc-ing that store accessed via SSH locally).
  • The derived LocalFSStore class has LocalFSStore::addPermRoot, which is not part of this class because it relies on the notion of an ambient file system. There are stores (ssh-ng://, for one), that do support garbage collection but don't expose any file system, and LocalFSStore::addPermRoot thus does not make sense for them.

Member Function Documentation

◆ collectGarbage()

virtual void nix::GcStore::collectGarbage ( const GCOptions & options,
GCResults & results )
pure virtual

Perform a garbage collection.

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

◆ deleteBuildTraces()

virtual void nix::GcStore::deleteBuildTraces ( const std::set< DrvOutput > & keys)
pure virtual

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

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

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

◆ findRoots()

virtual Roots nix::GcStore::findRoots ( bool censor)
pure virtual

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.

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


The documentation for this struct was generated from the following files:
  • libstore/include/nix/store/gc-store.hh
  • libstore/local-store.cc