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

#include <store-api.hh>

Inheritance diagram for nix::StoreConfig:
nix::StoreConfigBase nix::StoreDirConfig nix::Config nix::AbstractConfig nix::BinaryCacheStoreConfig nix::CommonSSHStoreConfig nix::DummyStoreConfig nix::HttpBinaryCacheStoreConfig nix::LocalBinaryCacheStoreConfig nix::LocalFSStoreConfig nix::RemoteStoreConfig nix::HttpBinaryCacheStoreConfig nix::LocalBinaryCacheStoreConfig nix::LegacySSHStoreConfig nix::SSHStoreConfig nix::S3BinaryCacheStoreConfig nix::testing::TestHttpBinaryCacheStoreConfig nix::LocalBuildStoreConfig nix::LocalStoreConfig nix::MountedSSHStoreConfig nix::UDSRemoteStoreConfig nix::SSHStoreConfig nix::UDSRemoteStoreConfig

Public Types

using Params = StoreReference::Params
Public Types inherited from nix::Config
using Settings = std::map<std::string, SettingData>

Public Member Functions

 StoreConfig (const Params &params, FilePathType pathType)
StringMap getQueryParams () const
virtual bool getReadOnly () const
virtual const std::filesystem::path & getStateDir () const
virtual const std::filesystem::path & getLogDir () const
virtual ref< Store > openStore () const =0
virtual StoreReference getReference () const
virtual std::string getHumanReadableURI () const
Public Member Functions inherited from nix::StoreConfigBase
 StoreConfigBase (const StoreReference::Params &params, FilePathType pathType)
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) const override
void resetOverridden () override
nlohmann::json toJSON () override
std::string toKeyValue (bool overriddenOnly=false) 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::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 Member Functions

static StringSet getDefaultSystemFeatures ()
static std::string doc ()
static std::optional< ExperimentalFeature > experimentalFeature ()

Public Attributes

Setting< int > pathInfoCacheSize
Setting< bool > isTrusted
Setting< int > priority
Setting< bool > wantMassQuery
Setting< StringSet > systemFeatures
Public Attributes inherited from nix::StoreConfigBase
StoreDirSetting storeDir_
Public Attributes inherited from nix::StoreDirConfig
const std::string & storeDir

Additional Inherited Members

Protected Types inherited from nix::StoreConfigBase
enum struct  FilePathType { Unix , Native }
Protected Member Functions inherited from nix::AbstractConfig
 AbstractConfig (StringMap initials={})
Protected Attributes inherited from nix::AbstractConfig
StringMap unknownSettings

Detailed Description

About the class hierarchy of the store types:

Each store type Foo consists of two classes:

  1. A class FooConfig : virtual StoreConfig that contains the configuration for the store

    It should only contain members of type Setting<T> (or subclasses of it) and inherit the constructors of StoreConfig (using StoreConfig::StoreConfig).

  2. A class Foo : virtual Store that contains the implementation of the store.

    This class is expected to have:

    1. an alias using Config = FooConfig;
    2. a constructor Foo(ref<const Config> params).

You can then register the new store using:

Definition store-registration.hh:93
Note
The order of StoreConfigBase and then StorerConfig is very important. This ensures that StoreConfigBase::storeDir_ is initialized before we have our one chance (because references are immutable) to initialize StoreConfig::storeDir.

Member Function Documentation

◆ doc()

std::string nix::StoreConfig::doc ( )
inlinestatic

Documentation for this type of store.

◆ experimentalFeature()

std::optional< ExperimentalFeature > nix::StoreConfig::experimentalFeature ( )
inlinestatic

An experimental feature this type store is gated, if it is to be experimental.

◆ getHumanReadableURI()

virtual std::string nix::StoreConfig::getHumanReadableURI ( ) const
inlinevirtual

Get a textual representation of the store reference.

Warning
This is only suitable for logging or error messages. This will not roundtrip when parsed as a StoreReference. Must NOT be used as a cache key or otherwise be relied upon to be stable.

Can be implemented by subclasses to make the URI more legible, e.g. when some query parameters are necessary to make sense of the URI.

Reimplemented in nix::S3BinaryCacheStoreConfig.

◆ getLogDir()

const std::filesystem::path & nix::StoreConfig::getLogDir ( ) const
virtual
Returns
The log directory for this store.

By default, returns the global log directory. Subclasses like LocalFSStoreConfig may override to return a store-specific log directory.

Reimplemented in nix::LocalFSStoreConfig.

◆ getQueryParams()

StringMap nix::StoreConfig::getQueryParams ( ) const
inline

Get overridden store reference query parameters.

◆ getReadOnly()

bool nix::StoreConfig::getReadOnly ( ) const
virtual

Whether we're allowed to write to this store, also takes into account global readOnly's mode setting, not just any per-store settings.

Reimplemented in nix::DummyStoreConfig, and nix::LocalStoreConfig.

◆ getReference()

StoreReference nix::StoreConfig::getReference ( ) const
virtual

Render the config back to a StoreReference. It should round-trip with resolveStoreConfig (for stores configs that are registered).

Reimplemented in nix::DummyStoreConfig, nix::HttpBinaryCacheStoreConfig, nix::LegacySSHStoreConfig, nix::LocalBinaryCacheStoreConfig, nix::LocalOverlayStoreConfig, nix::LocalStoreConfig, nix::SSHStoreConfig, and nix::UDSRemoteStoreConfig.

◆ getStateDir()

const std::filesystem::path & nix::StoreConfig::getStateDir ( ) const
virtual
Returns
The state directory for this store.

By default, returns the global settings.nixStateDir. Subclasses like LocalFSStoreConfig may override to return a store-specific state directory.

Reimplemented in nix::LocalFSStoreConfig.

◆ openStore()

Member Data Documentation

◆ isTrusted

Setting<bool> nix::StoreConfig::isTrusted
Initial value:
{
this,
false,
"trusted",
R"(
Whether paths from this store can be used as substitutes
even if they are not signed by a key listed in the
[`trusted-public-keys`](@docroot@/command-ref/conf-file.md#conf-trusted-public-keys)
setting.
)"}

◆ pathInfoCacheSize

Setting<int> nix::StoreConfig::pathInfoCacheSize
Initial value:
{
this, 65536, "path-info-cache-size", "Size of the in-memory store path metadata cache."}

◆ priority

Setting<int> nix::StoreConfig::priority
Initial value:
{
this,
0,
"priority",
R"(
Priority of this store when used as a [substituter](@docroot@/command-ref/conf-file.md#conf-substituters).
A lower value means a higher priority.
)"}

◆ systemFeatures

Setting<StringSet> nix::StoreConfig::systemFeatures
Initial value:
{
this,
getDefaultSystemFeatures(),
"system-features",
R"(
Optional [system features](@docroot@/command-ref/conf-file.md#conf-system-features) available on the system this store uses to build derivations.
Example: `"kvm"`
)",
{},
false}

◆ wantMassQuery

Setting<bool> nix::StoreConfig::wantMassQuery
Initial value:
{
this,
false,
"want-mass-query",
R"(
Whether this store can be queried efficiently for path validity when used as a [substituter](@docroot@/command-ref/conf-file.md#conf-substituters).
)"}

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