Skip to content

Commit

Permalink
doctor: print [INFO] for checkTrustedUser()
Browse files Browse the repository at this point in the history
This adds a new function checkInfo which prints with no consequence to
the exit code, we then use it to print whether the Nix client is a
trusted-user on the store
  • Loading branch information
MatthewCroughan committed Dec 27, 2022
1 parent 1dd6194 commit b03b43b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/nix/doctor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ bool checkFail(const std::string & msg) {
return false;
}

void checkInfo(const std::string & msg) {
notice(ANSI_BLUE "[INFO] " ANSI_NORMAL + msg);
}

}

struct CmdDoctor : StoreCommand
Expand All @@ -55,6 +59,7 @@ struct CmdDoctor : StoreCommand
success &= checkProfileRoots(store);
}
success &= checkStoreProtocol(store->getProtocol());
checkTrustedUser(store);

if (!success)
throw Exit(2);
Expand Down Expand Up @@ -130,6 +135,15 @@ struct CmdDoctor : StoreCommand

return checkPass("Client protocol matches store protocol.");
}

void checkTrustedUser(ref<Store> store)
{
bool trusted = store->checkTrustedUser();
if (trusted)
checkInfo("You are a trusted-user on store uri: " + store->getUri());
if (!trusted)
checkInfo("You are not a trusted-user on store uri: " + store->getUri());
}
};

static auto rCmdDoctor = registerCommand<CmdDoctor>("doctor");

0 comments on commit b03b43b

Please sign in to comment.