forked from lix-project/lix
Add a "root" parameter to local stores
This makes it easier to create a diverted store, i.e. NIX_REMOTE="local?root=/tmp/root" instead of NIX_REMOTE="local?real=/tmp/root/nix/store&state=/tmp/root/nix/var/nix" NIX_LOG_DIR=/tmp/root/nix/var/log
This commit is contained in:
parent
2fad86f361
commit
3eb6217508
|
@ -2910,7 +2910,7 @@ Path DerivationGoal::openLogFile()
|
||||||
string baseName = baseNameOf(drvPath);
|
string baseName = baseNameOf(drvPath);
|
||||||
|
|
||||||
/* Create a log file. */
|
/* Create a log file. */
|
||||||
Path dir = (format("%1%/%2%/%3%/") % settings.nixLogDir % drvsLogDir % string(baseName, 0, 2)).str();
|
Path dir = (format("%1%/%2%/%3%/") % worker.store.logDir % drvsLogDir % string(baseName, 0, 2)).str();
|
||||||
createDirs(dir);
|
createDirs(dir);
|
||||||
|
|
||||||
Path logFileName = (format("%1%/%2%%3%")
|
Path logFileName = (format("%1%/%2%%3%")
|
||||||
|
|
|
@ -7,7 +7,9 @@ namespace nix {
|
||||||
|
|
||||||
LocalFSStore::LocalFSStore(const Params & params)
|
LocalFSStore::LocalFSStore(const Params & params)
|
||||||
: Store(params)
|
: Store(params)
|
||||||
, stateDir(get(params, "state", settings.nixStateDir))
|
, rootDir(get(params, "root"))
|
||||||
|
, stateDir(canonPath(get(params, "state", rootDir != "" ? rootDir + "/nix/var/nix" : settings.nixStateDir)))
|
||||||
|
, logDir(canonPath(get(params, "log", rootDir != "" ? rootDir + "/nix/var/log/nix" : settings.nixLogDir)))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace nix {
|
||||||
|
|
||||||
LocalStore::LocalStore(const Params & params)
|
LocalStore::LocalStore(const Params & params)
|
||||||
: LocalFSStore(params)
|
: LocalFSStore(params)
|
||||||
, realStoreDir(get(params, "real", storeDir))
|
, realStoreDir(get(params, "real", rootDir != "" ? rootDir + "/nix/store" : storeDir))
|
||||||
, dbDir(stateDir + "/db")
|
, dbDir(stateDir + "/db")
|
||||||
, linksDir(realStoreDir + "/.links")
|
, linksDir(realStoreDir + "/.links")
|
||||||
, reservedPath(dbDir + "/reserved")
|
, reservedPath(dbDir + "/reserved")
|
||||||
|
|
|
@ -491,7 +491,9 @@ protected:
|
||||||
class LocalFSStore : public Store
|
class LocalFSStore : public Store
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
const Path rootDir;
|
||||||
const Path stateDir;
|
const Path stateDir;
|
||||||
|
const Path logDir;
|
||||||
|
|
||||||
LocalFSStore(const Params & params);
|
LocalFSStore(const Params & params);
|
||||||
|
|
||||||
|
|
|
@ -483,6 +483,10 @@ static void opReadLog(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
RunPager pager;
|
RunPager pager;
|
||||||
|
|
||||||
|
// FIXME: move getting logs into Store.
|
||||||
|
auto store2 = std::dynamic_pointer_cast<LocalFSStore>(store);
|
||||||
|
if (!store2) throw Error(format("store ‘%s’ does not support reading logs") % store->getUri());
|
||||||
|
|
||||||
for (auto & i : opArgs) {
|
for (auto & i : opArgs) {
|
||||||
Path path = useDeriver(store->followLinksToStorePath(i));
|
Path path = useDeriver(store->followLinksToStorePath(i));
|
||||||
|
|
||||||
|
@ -493,8 +497,8 @@ static void opReadLog(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
Path logPath =
|
Path logPath =
|
||||||
j == 0
|
j == 0
|
||||||
? (format("%1%/%2%/%3%/%4%") % settings.nixLogDir % drvsLogDir % string(baseName, 0, 2) % string(baseName, 2)).str()
|
? (format("%1%/%2%/%3%/%4%") % store2->logDir % drvsLogDir % string(baseName, 0, 2) % string(baseName, 2)).str()
|
||||||
: (format("%1%/%2%/%3%") % settings.nixLogDir % drvsLogDir % baseName).str();
|
: (format("%1%/%2%/%3%") % store2->logDir % drvsLogDir % baseName).str();
|
||||||
Path logBz2Path = logPath + ".bz2";
|
Path logBz2Path = logPath + ".bz2";
|
||||||
|
|
||||||
if (pathExists(logPath)) {
|
if (pathExists(logPath)) {
|
||||||
|
|
Loading…
Reference in a new issue