aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-10-08 16:30:04 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-10-08 17:00:55 +0200
commit21304c11f926892b1a0098ba5d424445d5ae30d6 (patch)
tree5ce12521b07099e4f9d481ae6eff88471f7c468c /src/libexpr
parent519aa479d7379981a3ffd914d734c33ee9610efd (diff)
uri -> url for consistency
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/flake/flake.cc17
-rw-r--r--src/libexpr/flake/lockfile.cc8
2 files changed, 16 insertions, 9 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 9e260263c..e8eb353fb 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -34,8 +34,14 @@ std::shared_ptr<FlakeRegistry> readRegistry(const Path & path)
throw Error("flake registry '%s' has unsupported version %d", path, version);
auto flakes = json["flakes"];
- for (auto i = flakes.begin(); i != flakes.end(); ++i)
- registry->entries.emplace(i.key(), FlakeRef(i->value("uri", "")));
+ for (auto i = flakes.begin(); i != flakes.end(); ++i) {
+ // FIXME: remove 'uri' soon.
+ auto url = i->value("url", i->value("uri", ""));
+ if (url.empty())
+ throw Error("flake registry '%s' lacks a 'url' attribute for entry '%s'",
+ path, i.key());
+ registry->entries.emplace(i.key(), url);
+ }
return registry;
}
@@ -46,7 +52,7 @@ void writeRegistry(const FlakeRegistry & registry, const Path & path)
nlohmann::json json;
json["version"] = 1;
for (auto elem : registry.entries)
- json["flakes"][elem.first.to_string()] = { {"uri", elem.second.to_string()} };
+ json["flakes"][elem.first.to_string()] = { {"url", elem.second.to_string()} };
createDirs(dirOf(path));
writeFile(path, json.dump(4)); // The '4' is the number of spaces used in the indentation in the json file.
}
@@ -283,7 +289,8 @@ static Flake getFlake(EvalState & state, const FlakeRef & originalRef,
}
auto sInputs = state.symbols.create("inputs");
- auto sUri = state.symbols.create("uri");
+ auto sUrl = state.symbols.create("url");
+ auto sUri = state.symbols.create("uri"); // FIXME: remove soon
auto sFlake = state.symbols.create("flake");
if (std::optional<Attr *> inputs = vInfo.attrs->get(sInputs)) {
@@ -295,7 +302,7 @@ static Flake getFlake(EvalState & state, const FlakeRef & originalRef,
FlakeInput input(FlakeRef(inputAttr.name));
for (Attr attr : *(inputAttr.value->attrs)) {
- if (attr.name == sUri) {
+ if (attr.name == sUrl || attr.name == sUri) {
expectType(state, tString, *attr.value, *attr.pos);
input.ref = std::string(attr.value->string.s);
} else if (attr.name == sFlake) {
diff --git a/src/libexpr/flake/lockfile.cc b/src/libexpr/flake/lockfile.cc
index 039b7a7c1..2c3f3c93d 100644
--- a/src/libexpr/flake/lockfile.cc
+++ b/src/libexpr/flake/lockfile.cc
@@ -5,8 +5,8 @@ namespace nix::flake {
LockedInput::LockedInput(const nlohmann::json & json)
: LockedInputs(json)
- , ref(json["uri"])
- , originalRef(json["originalUri"])
+ , ref(json.value("url", json.value("uri", "")))
+ , originalRef(json.value("originalUrl", json.value("originalUri", "")))
, narHash(Hash((std::string) json["narHash"]))
{
if (!ref.isImmutable())
@@ -16,8 +16,8 @@ LockedInput::LockedInput(const nlohmann::json & json)
nlohmann::json LockedInput::toJson() const
{
auto json = LockedInputs::toJson();
- json["uri"] = ref.to_string();
- json["originalUri"] = originalRef.to_string();
+ json["url"] = ref.to_string();
+ json["originalUrl"] = originalRef.to_string();
json["narHash"] = narHash.to_string(SRI);
return json;
}