From bd8c276ddbb980be2f9024c071cd304ef8a91b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Mon, 8 Apr 2024 11:02:39 +0200 Subject: [PATCH] Improve the `config check` output for stores that don't know about trust Make it proper english --- src/nix/config-check.cc | 11 ++++++++--- tests/functional/legacy-ssh-store.sh | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/nix/config-check.cc b/src/nix/config-check.cc index 661e1377b..f7c4cebec 100644 --- a/src/nix/config-check.cc +++ b/src/nix/config-check.cc @@ -145,9 +145,14 @@ struct CmdConfigCheck : StoreCommand void checkTrustedUser(ref store) { - auto trustedMay = store->isTrustedClient(); - std::string_view trustedness = trustedMay ? (*trustedMay ? "trusted" : "not trusted") : "unknown trust"; - checkInfo(fmt("You are %s by store uri: %s", trustedness, store->getUri())); + if (auto trustedMay = store->isTrustedClient()) { + std::string_view trusted = trustedMay.value() + ? "trusted" + : "not trusted"; + checkInfo(fmt("You are %s by store uri: %s", trusted, store->getUri())); + } else { + checkInfo(fmt("Store uri: %s doesn't have a notion of trusted user", store->getUri())); + } } }; diff --git a/tests/functional/legacy-ssh-store.sh b/tests/functional/legacy-ssh-store.sh index 79c3fba82..56b4c2d20 100644 --- a/tests/functional/legacy-ssh-store.sh +++ b/tests/functional/legacy-ssh-store.sh @@ -6,4 +6,4 @@ store_uri="ssh://localhost?remote-store=$TEST_ROOT/other-store" nix --store "$store_uri" store info --json | jq -e 'has("trusted") | not' # Suppress grumpiness about multiple nixes on PATH -(nix --store "$store_uri" doctor || true) 2>&1 | grep 'You are unknown trust' +(nix --store "$store_uri" doctor || true) 2>&1 | grep "doesn't have a notion of trusted user"