mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
StoreAPI -> Store
Calling a class an API is a bit redundant...
This commit is contained in:
parent
c10c61449f
commit
fa7cd5369b
24 changed files with 51 additions and 51 deletions
|
@ -19,9 +19,9 @@
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
|
|
||||||
|
|
||||||
static ref<StoreAPI> store()
|
static ref<Store> store()
|
||||||
{
|
{
|
||||||
static std::shared_ptr<StoreAPI> _store;
|
static std::shared_ptr<Store> _store;
|
||||||
if (!_store) {
|
if (!_store) {
|
||||||
try {
|
try {
|
||||||
settings.processEnvironment();
|
settings.processEnvironment();
|
||||||
|
@ -33,7 +33,7 @@ static ref<StoreAPI> store()
|
||||||
croak("%s", e.what());
|
croak("%s", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ref<StoreAPI>(_store);
|
return ref<Store>(_store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
class StoreAPI;
|
class Store;
|
||||||
|
|
||||||
/* Some common option parsing between nix-env and nix-instantiate. */
|
/* Some common option parsing between nix-env and nix-instantiate. */
|
||||||
bool parseAutoArgs(Strings::iterator & i,
|
bool parseAutoArgs(Strings::iterator & i,
|
||||||
|
|
|
@ -244,7 +244,7 @@ static Strings parseNixPath(const string & in)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EvalState::EvalState(const Strings & _searchPath, ref<StoreAPI> store)
|
EvalState::EvalState(const Strings & _searchPath, ref<Store> store)
|
||||||
: sWith(symbols.create("<with>"))
|
: sWith(symbols.create("<with>"))
|
||||||
, sOutPath(symbols.create("outPath"))
|
, sOutPath(symbols.create("outPath"))
|
||||||
, sDrvPath(symbols.create("drvPath"))
|
, sDrvPath(symbols.create("drvPath"))
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
||||||
class StoreAPI;
|
class Store;
|
||||||
class EvalState;
|
class EvalState;
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public:
|
||||||
|
|
||||||
Value vEmptySet;
|
Value vEmptySet;
|
||||||
|
|
||||||
const ref<StoreAPI> store;
|
const ref<Store> store;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SrcToStore srcToStore;
|
SrcToStore srcToStore;
|
||||||
|
@ -100,7 +100,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EvalState(const Strings & _searchPath, ref<StoreAPI> store);
|
EvalState(const Strings & _searchPath, ref<Store> store);
|
||||||
~EvalState();
|
~EvalState();
|
||||||
|
|
||||||
void addToSearchPath(const string & s, bool warn = false);
|
void addToSearchPath(const string & s, bool warn = false);
|
||||||
|
|
|
@ -46,7 +46,7 @@ void printGCWarning()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void printMissing(ref<StoreAPI> store, const PathSet & paths)
|
void printMissing(ref<Store> store, const PathSet & paths)
|
||||||
{
|
{
|
||||||
unsigned long long downloadSize, narSize;
|
unsigned long long downloadSize, narSize;
|
||||||
PathSet willBuild, willSubstitute, unknown;
|
PathSet willBuild, willSubstitute, unknown;
|
||||||
|
@ -55,7 +55,7 @@ void printMissing(ref<StoreAPI> store, const PathSet & paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void printMissing(ref<StoreAPI> store, const PathSet & willBuild,
|
void printMissing(ref<Store> store, const PathSet & willBuild,
|
||||||
const PathSet & willSubstitute, const PathSet & unknown,
|
const PathSet & willSubstitute, const PathSet & unknown,
|
||||||
unsigned long long downloadSize, unsigned long long narSize)
|
unsigned long long downloadSize, unsigned long long narSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,11 +31,11 @@ void printVersion(const string & programName);
|
||||||
/* Ugh. No better place to put this. */
|
/* Ugh. No better place to put this. */
|
||||||
void printGCWarning();
|
void printGCWarning();
|
||||||
|
|
||||||
class StoreAPI;
|
class Store;
|
||||||
|
|
||||||
void printMissing(ref<StoreAPI> store, const PathSet & paths);
|
void printMissing(ref<Store> store, const PathSet & paths);
|
||||||
|
|
||||||
void printMissing(ref<StoreAPI> store, const PathSet & willBuild,
|
void printMissing(ref<Store> store, const PathSet & willBuild,
|
||||||
const PathSet & willSubstitute, const PathSet & unknown,
|
const PathSet & willSubstitute, const PathSet & unknown,
|
||||||
unsigned long long downloadSize, unsigned long long narSize);
|
unsigned long long downloadSize, unsigned long long narSize);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ bool BasicDerivation::canBuildLocally() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path writeDerivation(ref<StoreAPI> store,
|
Path writeDerivation(ref<Store> store,
|
||||||
const Derivation & drv, const string & name, bool repair)
|
const Derivation & drv, const string & name, bool repair)
|
||||||
{
|
{
|
||||||
PathSet references;
|
PathSet references;
|
||||||
|
@ -274,7 +274,7 @@ DrvHashes drvHashes;
|
||||||
paths have been replaced by the result of a recursive call to this
|
paths have been replaced by the result of a recursive call to this
|
||||||
function, and that for fixed-output derivations we return a hash of
|
function, and that for fixed-output derivations we return a hash of
|
||||||
its output path. */
|
its output path. */
|
||||||
Hash hashDerivationModulo(StoreAPI & store, Derivation drv)
|
Hash hashDerivationModulo(Store & store, Derivation drv)
|
||||||
{
|
{
|
||||||
/* Return a fixed hash for fixed-output derivations. */
|
/* Return a fixed hash for fixed-output derivations. */
|
||||||
if (drv.isFixedOutput()) {
|
if (drv.isFixedOutput()) {
|
||||||
|
|
|
@ -80,11 +80,11 @@ struct Derivation : BasicDerivation
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class StoreAPI;
|
class Store;
|
||||||
|
|
||||||
|
|
||||||
/* Write a derivation to the Nix store, and return its path. */
|
/* Write a derivation to the Nix store, and return its path. */
|
||||||
Path writeDerivation(ref<StoreAPI> store,
|
Path writeDerivation(ref<Store> store,
|
||||||
const Derivation & drv, const string & name, bool repair = false);
|
const Derivation & drv, const string & name, bool repair = false);
|
||||||
|
|
||||||
/* Read a derivation from a file. */
|
/* Read a derivation from a file. */
|
||||||
|
@ -94,7 +94,7 @@ Derivation readDerivation(const Path & drvPath);
|
||||||
derivations. */
|
derivations. */
|
||||||
bool isDerivation(const string & fileName);
|
bool isDerivation(const string & fileName);
|
||||||
|
|
||||||
Hash hashDerivationModulo(StoreAPI & store, Derivation drv);
|
Hash hashDerivationModulo(Store & store, Derivation drv);
|
||||||
|
|
||||||
/* Memoisation of hashDerivationModulo(). */
|
/* Memoisation of hashDerivationModulo(). */
|
||||||
typedef std::map<Path, Hash> DrvHashes;
|
typedef std::map<Path, Hash> DrvHashes;
|
||||||
|
|
|
@ -188,7 +188,7 @@ DownloadResult downloadFile(string url, const DownloadOptions & options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path downloadFileCached(ref<StoreAPI> store, const string & url, bool unpack)
|
Path downloadFileCached(ref<Store> store, const string & url, bool unpack)
|
||||||
{
|
{
|
||||||
Path cacheDir = getEnv("XDG_CACHE_HOME", getEnv("HOME", "") + "/.cache") + "/nix/tarballs";
|
Path cacheDir = getEnv("XDG_CACHE_HOME", getEnv("HOME", "") + "/.cache") + "/nix/tarballs";
|
||||||
createDirs(cacheDir);
|
createDirs(cacheDir);
|
||||||
|
|
|
@ -19,11 +19,11 @@ struct DownloadResult
|
||||||
string data, etag;
|
string data, etag;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StoreAPI;
|
class Store;
|
||||||
|
|
||||||
DownloadResult downloadFile(string url, const DownloadOptions & options);
|
DownloadResult downloadFile(string url, const DownloadOptions & options);
|
||||||
|
|
||||||
Path downloadFileCached(ref<StoreAPI> store, const string & url, bool unpack);
|
Path downloadFileCached(ref<Store> store, const string & url, bool unpack);
|
||||||
|
|
||||||
MakeError(DownloadError, Error)
|
MakeError(DownloadError, Error)
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ void LocalStore::addIndirectRoot(const Path & path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path addPermRoot(ref<StoreAPI> store, const Path & _storePath,
|
Path addPermRoot(ref<Store> store, const Path & _storePath,
|
||||||
const Path & _gcRoot, bool indirect, bool allowOutsideRootsDir)
|
const Path & _gcRoot, bool indirect, bool allowOutsideRootsDir)
|
||||||
{
|
{
|
||||||
Path storePath(canonPath(_storePath));
|
Path storePath(canonPath(_storePath));
|
||||||
|
|
|
@ -80,7 +80,7 @@ struct SQLiteStmt
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class LocalStore : public StoreAPI
|
class LocalStore : public Store
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef std::map<Path, RunningSubstituter> RunningSubstituters;
|
typedef std::map<Path, RunningSubstituter> RunningSubstituters;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
||||||
Derivation StoreAPI::derivationFromPath(const Path & drvPath)
|
Derivation Store::derivationFromPath(const Path & drvPath)
|
||||||
{
|
{
|
||||||
assertStorePath(drvPath);
|
assertStorePath(drvPath);
|
||||||
ensurePath(drvPath);
|
ensurePath(drvPath);
|
||||||
|
@ -15,7 +15,7 @@ Derivation StoreAPI::derivationFromPath(const Path & drvPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StoreAPI::computeFSClosure(const Path & path,
|
void Store::computeFSClosure(const Path & path,
|
||||||
PathSet & paths, bool flipDirection, bool includeOutputs, bool includeDerivers)
|
PathSet & paths, bool flipDirection, bool includeOutputs, bool includeDerivers)
|
||||||
{
|
{
|
||||||
if (paths.find(path) != paths.end()) return;
|
if (paths.find(path) != paths.end()) return;
|
||||||
|
@ -59,7 +59,7 @@ void StoreAPI::computeFSClosure(const Path & path,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StoreAPI::queryMissing(const PathSet & targets,
|
void Store::queryMissing(const PathSet & targets,
|
||||||
PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
|
PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
|
||||||
unsigned long long & downloadSize, unsigned long long & narSize)
|
unsigned long long & downloadSize, unsigned long long & narSize)
|
||||||
{
|
{
|
||||||
|
@ -173,7 +173,7 @@ void StoreAPI::queryMissing(const PathSet & targets,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Paths StoreAPI::topoSortPaths(const PathSet & paths)
|
Paths Store::topoSortPaths(const PathSet & paths)
|
||||||
{
|
{
|
||||||
Paths sorted;
|
Paths sorted;
|
||||||
PathSet visited, parents;
|
PathSet visited, parents;
|
||||||
|
|
|
@ -74,7 +74,7 @@ static void makeName(const Path & profile, unsigned int num,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path createGeneration(ref<StoreAPI> store, Path profile, Path outPath)
|
Path createGeneration(ref<Store> store, Path profile, Path outPath)
|
||||||
{
|
{
|
||||||
/* The new generation number should be higher than old the
|
/* The new generation number should be higher than old the
|
||||||
previous ones. */
|
previous ones. */
|
||||||
|
|
|
@ -31,9 +31,9 @@ typedef list<Generation> Generations;
|
||||||
profile, sorted by generation number. */
|
profile, sorted by generation number. */
|
||||||
Generations findGenerations(Path profile, int & curGen);
|
Generations findGenerations(Path profile, int & curGen);
|
||||||
|
|
||||||
class StoreAPI;
|
class Store;
|
||||||
|
|
||||||
Path createGeneration(ref<StoreAPI> store, Path profile, Path outPath);
|
Path createGeneration(ref<Store> store, Path profile, Path outPath);
|
||||||
|
|
||||||
void deleteGeneration(const Path & profile, unsigned int gen);
|
void deleteGeneration(const Path & profile, unsigned int gen);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct FdSink;
|
||||||
struct FdSource;
|
struct FdSource;
|
||||||
|
|
||||||
|
|
||||||
class RemoteStore : public StoreAPI
|
class RemoteStore : public Store
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ Path computeStorePathForText(const string & name, const string & s,
|
||||||
/* Return a string accepted by decodeValidPathInfo() that
|
/* Return a string accepted by decodeValidPathInfo() that
|
||||||
registers the specified paths as valid. Note: it's the
|
registers the specified paths as valid. Note: it's the
|
||||||
responsibility of the caller to provide a closure. */
|
responsibility of the caller to provide a closure. */
|
||||||
string StoreAPI::makeValidityRegistration(const PathSet & paths,
|
string Store::makeValidityRegistration(const PathSet & paths,
|
||||||
bool showDerivers, bool showHash)
|
bool showDerivers, bool showHash)
|
||||||
{
|
{
|
||||||
string s = "";
|
string s = "";
|
||||||
|
@ -284,7 +284,7 @@ string showPaths(const PathSet & paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StoreAPI::exportPaths(const Paths & paths,
|
void Store::exportPaths(const Paths & paths,
|
||||||
bool sign, Sink & sink)
|
bool sign, Sink & sink)
|
||||||
{
|
{
|
||||||
for (auto & i : paths) {
|
for (auto & i : paths) {
|
||||||
|
@ -306,7 +306,7 @@ void StoreAPI::exportPaths(const Paths & paths,
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
||||||
ref<StoreAPI> openStore(bool reserveSpace)
|
ref<Store> openStore(bool reserveSpace)
|
||||||
{
|
{
|
||||||
enum { mDaemon, mLocal, mAuto } mode;
|
enum { mDaemon, mLocal, mAuto } mode;
|
||||||
|
|
||||||
|
@ -322,8 +322,8 @@ ref<StoreAPI> openStore(bool reserveSpace)
|
||||||
}
|
}
|
||||||
|
|
||||||
return mode == mDaemon
|
return mode == mDaemon
|
||||||
? make_ref<StoreAPI, RemoteStore>()
|
? make_ref<Store, RemoteStore>()
|
||||||
: make_ref<StoreAPI, LocalStore>(reserveSpace);
|
: make_ref<Store, LocalStore>(reserveSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -135,11 +135,11 @@ struct BasicDerivation;
|
||||||
struct Derivation;
|
struct Derivation;
|
||||||
|
|
||||||
|
|
||||||
class StoreAPI
|
class Store
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~StoreAPI() { }
|
virtual ~Store() { }
|
||||||
|
|
||||||
/* Check whether a path is valid. */
|
/* Check whether a path is valid. */
|
||||||
virtual bool isValidPath(const Path & path) = 0;
|
virtual bool isValidPath(const Path & path) = 0;
|
||||||
|
@ -407,13 +407,13 @@ void removeTempRoots();
|
||||||
|
|
||||||
|
|
||||||
/* Register a permanent GC root. */
|
/* Register a permanent GC root. */
|
||||||
Path addPermRoot(ref<StoreAPI> store, const Path & storePath,
|
Path addPermRoot(ref<Store> store, const Path & storePath,
|
||||||
const Path & gcRoot, bool indirect, bool allowOutsideRootsDir = false);
|
const Path & gcRoot, bool indirect, bool allowOutsideRootsDir = false);
|
||||||
|
|
||||||
|
|
||||||
/* Factory method: open the Nix database, either through the local or
|
/* Factory method: open the Nix database, either through the local or
|
||||||
remote implementation. */
|
remote implementation. */
|
||||||
ref<StoreAPI> openStore(bool reserveSpace = true);
|
ref<Store> openStore(bool reserveSpace = true);
|
||||||
|
|
||||||
|
|
||||||
/* Display a set of paths in human-readable form (i.e., between quotes
|
/* Display a set of paths in human-readable form (i.e., between quotes
|
||||||
|
|
|
@ -32,7 +32,7 @@ static bool indirectRoot = false;
|
||||||
enum OutputKind { okPlain, okXML, okJSON };
|
enum OutputKind { okPlain, okXML, okJSON };
|
||||||
|
|
||||||
|
|
||||||
void processExpr(ref<StoreAPI> store, EvalState & state, const Strings & attrPaths,
|
void processExpr(ref<Store> store, EvalState & state, const Strings & attrPaths,
|
||||||
bool parseOnly, bool strict, Bindings & autoArgs,
|
bool parseOnly, bool strict, Bindings & autoArgs,
|
||||||
bool evalOnly, OutputKind output, bool location, Expr * e)
|
bool evalOnly, OutputKind output, bool location, Expr * e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,7 +94,7 @@ void printClosure(const Path & nePath, const StoreExpr & fs)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void printDotGraph(StoreAPI & store, const PathSet & roots)
|
void printDotGraph(Store & store, const PathSet & roots)
|
||||||
{
|
{
|
||||||
PathSet workList(roots);
|
PathSet workList(roots);
|
||||||
PathSet doneSet;
|
PathSet doneSet;
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
class StoreAPI;
|
class Store;
|
||||||
|
|
||||||
void printDotGraph(StoreAPI & store, const PathSet & roots);
|
void printDotGraph(Store & store, const PathSet & roots);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ static Path gcRoot;
|
||||||
static int rootNr = 0;
|
static int rootNr = 0;
|
||||||
static bool indirectRoot = false;
|
static bool indirectRoot = false;
|
||||||
static bool noOutput = false;
|
static bool noOutput = false;
|
||||||
static std::shared_ptr<StoreAPI> store;
|
static std::shared_ptr<Store> store;
|
||||||
|
|
||||||
|
|
||||||
LocalStore & ensureLocalStore()
|
LocalStore & ensureLocalStore()
|
||||||
|
@ -84,7 +84,7 @@ static PathSet realisePath(Path path, bool build = true)
|
||||||
Path rootName = gcRoot;
|
Path rootName = gcRoot;
|
||||||
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
||||||
if (i->first != "out") rootName += "-" + i->first;
|
if (i->first != "out") rootName += "-" + i->first;
|
||||||
outPath = addPermRoot(ref<StoreAPI>(store), outPath, rootName, indirectRoot);
|
outPath = addPermRoot(ref<Store>(store), outPath, rootName, indirectRoot);
|
||||||
}
|
}
|
||||||
outputs.insert(outPath);
|
outputs.insert(outPath);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ static PathSet realisePath(Path path, bool build = true)
|
||||||
Path rootName = gcRoot;
|
Path rootName = gcRoot;
|
||||||
rootNr++;
|
rootNr++;
|
||||||
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
||||||
path = addPermRoot(ref<StoreAPI>(store), path, rootName, indirectRoot);
|
path = addPermRoot(ref<Store>(store), path, rootName, indirectRoot);
|
||||||
}
|
}
|
||||||
return singleton<PathSet>(path);
|
return singleton<PathSet>(path);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ static void opRealise(Strings opFlags, Strings opArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.get("print-missing", true))
|
if (settings.get("print-missing", true))
|
||||||
printMissing(ref<StoreAPI>(store), willBuild, willSubstitute, unknown, downloadSize, narSize);
|
printMissing(ref<Store>(store), willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||||
|
|
||||||
if (dryRun) return;
|
if (dryRun) return;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ static string makeNode(const string & id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void printXmlGraph(StoreAPI & store, const PathSet & roots)
|
void printXmlGraph(Store & store, const PathSet & roots)
|
||||||
{
|
{
|
||||||
PathSet workList(roots);
|
PathSet workList(roots);
|
||||||
PathSet doneSet;
|
PathSet doneSet;
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
class StoreAPI;
|
class Store;
|
||||||
|
|
||||||
void printXmlGraph(StoreAPI & store, const PathSet & roots);
|
void printXmlGraph(Store & store, const PathSet & roots);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue