diff --git a/doc/manual/src/release-notes/rl-next.md b/doc/manual/src/release-notes/rl-next.md index dde2328088f..842cd1e0a91 100644 --- a/doc/manual/src/release-notes/rl-next.md +++ b/doc/manual/src/release-notes/rl-next.md @@ -29,3 +29,7 @@ * New command: `nix store check-trusted`, which checks if you are a trusted-user, returning 1 or 0. This is useful for scripting interactions with remote Nix stores. + +* `nix doctor` now prints `[INFO]` instead of just `[PASS]` or `[FAIL]` and will + use the `nix store check-trusted` function to print whether you are a + trusted-user or not. diff --git a/src/nix/doctor.cc b/src/nix/doctor.cc index ea87e3d8744..411ed997f00 100644 --- a/src/nix/doctor.cc +++ b/src/nix/doctor.cc @@ -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 @@ -55,6 +59,7 @@ struct CmdDoctor : StoreCommand success &= checkProfileRoots(store); } success &= checkStoreProtocol(store->getProtocol()); + checkTrustedUser(store); if (!success) throw Exit(2); @@ -130,6 +135,15 @@ struct CmdDoctor : StoreCommand return checkPass("Client protocol matches store protocol."); } + + void checkTrustedUser(ref 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("doctor");