Include fetcher input scheme info in the CLI dump

Leverages the previous commit.
This commit is contained in:
John Ericson 2023-10-30 10:30:59 -04:00
parent 8381eeda6f
commit 077de2968e
3 changed files with 17 additions and 0 deletions

View file

@ -19,6 +19,19 @@ void registerInputScheme(std::shared_ptr<InputScheme> && inputScheme)
inputSchemes->insert_or_assign(schemeName, std::move(inputScheme));
}
nlohmann::json dumpRegisterInputSchemeInfo() {
using nlohmann::json;
auto res = json::object();
for (auto & [name, scheme] : *inputSchemes) {
auto & r = res[name] = json::object();
r["allowedAttrs"] = scheme->allowedAttrs();
}
return res;
}
Input Input::fromURL(const std::string & url, bool requireTree)
{
return fromURL(parseURL(url), requireTree);

View file

@ -8,6 +8,7 @@
#include "url.hh"
#include <memory>
#include <nlohmann/json_fwd.hpp>
namespace nix { class Store; }
@ -170,4 +171,6 @@ struct InputScheme
void registerInputScheme(std::shared_ptr<InputScheme> && fetcher);
nlohmann::json dumpRegisterInputSchemeInfo();
}

View file

@ -188,6 +188,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs
j["experimentalFeature"] = storeConfig->experimentalFeature();
}
res["stores"] = std::move(stores);
res["fetchers"] = fetchers::dumpRegisterInputSchemeInfo();
return res.dump();
}