mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 06:26:15 +02:00
nix doctor: add check for profile roots
In most cases profiles that are in PATH should have a gcroot.
This commit is contained in:
parent
0f18dc5479
commit
bfdca55868
1 changed files with 35 additions and 0 deletions
|
@ -34,6 +34,7 @@ struct CmdDoctor : StoreCommand
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
checkNixInPath();
|
checkNixInPath();
|
||||||
|
checkProfileRoots(store);
|
||||||
checkStoreProtocol(store->getProtocol());
|
checkStoreProtocol(store->getProtocol());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +54,40 @@ struct CmdDoctor : StoreCommand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkProfileRoots(ref<Store> store) {
|
||||||
|
PathSet dirs;
|
||||||
|
|
||||||
|
Roots roots = store->findRoots();
|
||||||
|
|
||||||
|
for (auto & dir : tokenizeString<Strings>(getEnv("PATH"), ":"))
|
||||||
|
try {
|
||||||
|
auto profileDir = canonPath(dirOf(dir), true);
|
||||||
|
if (hasSuffix(profileDir, "user-environment") &&
|
||||||
|
store->isValidPath(profileDir)) {
|
||||||
|
PathSet referrers;
|
||||||
|
store->computeFSClosure({profileDir}, referrers, true,
|
||||||
|
settings.gcKeepOutputs, settings.gcKeepDerivations);
|
||||||
|
bool found = false;
|
||||||
|
for (auto & i : roots)
|
||||||
|
if (referrers.find(i.second) != referrers.end())
|
||||||
|
found = true;
|
||||||
|
if (!found)
|
||||||
|
dirs.insert(dir);
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (SysError &) {}
|
||||||
|
|
||||||
|
if (!dirs.empty()) {
|
||||||
|
std::cout << "Warning: found profiles without a gcroot." << std::endl;
|
||||||
|
std::cout << "The generation this profile points to will be deleted with the next gc, resulting" << std::endl;
|
||||||
|
std::cout << "in broken symlinks. Make sure your profiles are in " << settings.nixStateDir << "/profiles." << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
for (auto & dir : dirs)
|
||||||
|
std::cout << " " << dir << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void checkStoreProtocol(unsigned int storeProto) {
|
void checkStoreProtocol(unsigned int storeProto) {
|
||||||
auto clientProto = GET_PROTOCOL_MAJOR(SERVE_PROTOCOL_VERSION) == GET_PROTOCOL_MAJOR(storeProto)
|
auto clientProto = GET_PROTOCOL_MAJOR(SERVE_PROTOCOL_VERSION) == GET_PROTOCOL_MAJOR(storeProto)
|
||||||
? SERVE_PROTOCOL_VERSION
|
? SERVE_PROTOCOL_VERSION
|
||||||
|
|
Loading…
Reference in a new issue