Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
store-api.hh File Reference
#include "lix/libutil/archive.hh"
#include "lix/libutil/async-io.hh"
#include "lix/libutil/async.hh"
#include "lix/libutil/json-fwd.hh"
#include "lix/libutil/logging.hh"
#include "lix/libstore/nar-info.hh"
#include "lix/libstore/realisation.hh"
#include "lix/libstore/path.hh"
#include "lix/libstore/derived-path.hh"
#include "lix/libutil/hash.hh"
#include "lix/libstore/content-address.hh"
#include "lix/libutil/result.hh"
#include "lix/libutil/serialise.hh"
#include "lix/libutil/lru-cache.hh"
#include "lix/libutil/sync.hh"
#include "lix/libstore/globals.hh"
#include "lix/libutil/config.hh"
#include "lix/libstore/path-info.hh"
#include "lix/libutil/repair-flag.hh"
#include "lix/libutil/source-path.hh"
#include <kj/async.h>
#include <atomic>
#include <limits>
#include <map>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <string>
#include <chrono>
#include <variant>

Go to the source code of this file.

Classes

struct  nix::json::is_integral_enum< TrustedFlag >
struct  nix::StoreConfig
class  nix::Store
struct  nix::Store::PathInfoCacheValue
struct  nix::Store::State
struct  nix::Store::AssociatedCredentials
struct  nix::Store::Stats< Wrapper >
struct  nix::StoreFactory
struct  nix::StoreImplementations

Typedefs

typedef std::map< std::string, StorePathnix::OutputPathMap
typedef std::map< StorePath, std::optional< ContentAddress > > nix::StorePathCAMap

Enumerations

enum  CheckSigsFlag : bool { NoCheckSigs = false , CheckSigs = true }
enum  SubstituteFlag : bool { NoSubstitute = false , Substitute = true }
enum  AllowInvalidFlag : bool { DisallowInvalid = false , AllowInvalid = true }
enum  BuildMode { bmNormal , bmRepair , bmCheck }
enum  TrustedFlag : bool { NotTrusted = false , Trusted = true }

Functions

 nix::MakeError (SubstError, Error)
 nix::MakeError (BuildError, Error)
 nix::MakeError (InvalidPath, Error)
 nix::MakeError (Unsupported, Error)
 nix::MakeError (SubstituteGone, Error)
 nix::MakeError (SubstituterDisabled, Error)
 nix::MakeError (BadStorePath, Error)
 nix::MakeError (InvalidStoreURI, Error)
BuildMode nix::buildModeFromInteger (int raw)
kj::Promise< Result< void > > nix::copyStorePath (Store &srcStore, Store &dstStore, const StorePath &storePath, RepairFlag repair, CheckSigsFlag checkSigs)
kj::Promise< Result< std::map< StorePath, StorePath > > > nix::copyPaths (Store &srcStore, Store &dstStore, const RealisedPath::Set &paths, RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute)
kj::Promise< Result< std::map< StorePath, StorePath > > > nix::copyPaths (Store &srcStore, Store &dstStore, const StorePathSet &storePaths, RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute)
kj::Promise< Result< void > > nix::copyClosure (Store &srcStore, Store &dstStore, const RealisedPath::Set &paths, RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute)
kj::Promise< Result< void > > nix::copyClosure (Store &srcStore, Store &dstStore, const StorePathSet &storePaths, RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute)
void nix::removeTempRoots ()
kj ::Promise< Result< StorePath > > nix::resolveDerivedPath (Store &store, const SingleDerivedPath &req, Store *evalStore_)
kj::Promise< Result< OutputPathMap > > nix::resolveDerivedPath (Store &store, const DerivedPath::Built &bfd, Store *evalStore_)
kj::Promise< Result< ref< Store > > > nix::openStore (const std::string &uri_, const StoreConfig::Params &extraParams)
kj::Promise< Result< std::list< ref< Store > > > > nix::getDefaultSubstituters ()
std::string nix::showPaths (const PathSet &paths)
std::optional< ValidPathInfonix::decodeValidPathInfo (const Store &store, std::istream &str, std::optional< HashResult > hashGiven)
std::pair< std::string, StoreConfig::Params > nix::splitUriAndParams (const std::string &uri_)
const ContentAddressnix::getDerivationCA (const BasicDerivation &drv)
kj::Promise< Result< std::map< DrvOutput, StorePath > > > nix::drvOutputReferences (Store &store, const Derivation &drv, const StorePath &outputPath, Store *evalStore_)

Variables

const uint32_t nix::exportMagic = 0x4558494e

Function Documentation

◆ buildModeFromInteger()

BuildMode nix::buildModeFromInteger ( int )

Checks that a build mode is a valid one, then returns it

◆ copyClosure()

kj::Promise< Result< void > > nix::copyClosure ( Store & srcStore,
Store & dstStore,
const RealisedPath::Set & paths,
RepairFlag repair = NoRepair,
CheckSigsFlag checkSigs = CheckSigs,
SubstituteFlag substitute = NoSubstitute )

Copy the closure of paths from srcStore to dstStore.

◆ copyPaths()

kj::Promise< Result< std::map< StorePath, StorePath > > > nix::copyPaths ( Store & srcStore,
Store & dstStore,
const RealisedPath::Set & ,
RepairFlag repair = NoRepair,
CheckSigsFlag checkSigs = CheckSigs,
SubstituteFlag substitute = NoSubstitute )

Copy store paths from one store to another. The paths may be copied in parallel. They are copied in a topologically sorted order (i.e. if A is a reference of B, then A is copied before B), but the set of store paths is not automatically closed; use copyClosure() for that.

Returns
a map of what each path was copied to the dstStore as.

◆ copyStorePath()

kj::Promise< Result< void > > nix::copyStorePath ( Store & srcStore,
Store & dstStore,
const StorePath & storePath,
RepairFlag repair = NoRepair,
CheckSigsFlag checkSigs = CheckSigs )

Copy a path from one store to another.

◆ getDefaultSubstituters()

kj::Promise< Result< std::list< ref< Store > > > > nix::getDefaultSubstituters ( )
Returns
the default substituter stores, defined by the ‘substituters’ option and various legacy options.

◆ MakeError() [1/4]

nix::MakeError ( BadStorePath ,
Error  )

denotes that a path could not possibly be a store path. e.g. outside of the nix store, illegal characters in the name, etc.

◆ MakeError() [2/4]

nix::MakeError ( BuildError ,
Error  )

denotes a permanent build failure

◆ MakeError() [3/4]

nix::MakeError ( InvalidPath ,
Error  )

denotes that a path in the store did not exist (but it could, had it been put there, i.e. it is still legal).

◆ MakeError() [4/4]

nix::MakeError ( SubstError ,
Error  )

About the class hierarchy of the store implementations:

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 const 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 a constructor Foo(FooConfig config) that calls StoreConfig(config) (otherwise you're gonna encounter an assertion failure when trying to instantiate it).

You can then register the new store by defining a registration function (using StoreImplementations::add) and calling it in registerStoreImplementations in globals.cc.

◆ openStore()

kj::Promise< Result< ref< Store > > > nix::openStore ( const std::string & uri = settings.storeUri.get(),
const StoreConfig::Params & extraParams = {} )
Returns
a Store object to access the Nix store denoted by ‘uri’ (slight misnomer...).
Parameters
uriSupported values are:
  • ‘local’: The Nix store in /nix/store and database in /nix/var/nix/db, accessed directly.
  • ‘daemon’: The Nix store accessed via a Unix domain socket connection to nix-daemon.
  • ‘unix://<path>’: The Nix store accessed via a Unix domain socket connection to nix-daemon, with the socket located at <path>.
  • ‘auto’ or ‘’: Equivalent to ‘local’ or ‘daemon’ depending on whether the user has write access to the local Nix store/database.
  • ‘file://<path>’: A binary cache stored in <path>.
  • ‘https://<path>’: A binary cache accessed via HTTP.
  • ‘s3://<path>’: A writable binary cache stored on Amazon's Simple Storage Service.
  • ‘ssh://[user@]<host>’: A remote Nix store accessed by running ‘nix-store –serve’ via SSH.

You can pass parameters to the store implementation by appending ‘?key=value&key=value&...’ to the URI.

◆ removeTempRoots()

void nix::removeTempRoots ( )

Remove the temporary roots file for this process. Any temporary root becomes garbage after this point unless it has been registered as a (permanent) root.

◆ resolveDerivedPath()

kj::Promise< Result< StorePath > > nix::resolveDerivedPath ( Store & ,
const SingleDerivedPath & ,
Store * evalStore = nullptr )

Resolve the derived path completely, failing if any derivation output is unknown.

◆ showPaths()

std::string nix::showPaths ( const PathSet & paths)

Display a set of paths in human-readable form (i.e., between quotes and separated by commas).

◆ splitUriAndParams()

std::pair< std::string, StoreConfig::Params > nix::splitUriAndParams ( const std::string & uri)

Split URI into protocol+hierarchy part and its parameter set.

Variable Documentation

◆ exportMagic

const uint32_t nix::exportMagic = 0x4558494e

Magic header of exportPath() output (obsolete).