uri -> url for consistency
This commit is contained in:
parent
519aa479d7
commit
21304c11f9
|
@ -3,8 +3,8 @@
|
|||
"nixpkgs": {
|
||||
"inputs": {},
|
||||
"narHash": "sha256-ltGlDPfwicH/u4orj1n4JXgRsA+jvKQsGnekObi0TV4=",
|
||||
"originalUri": "nixpkgs/release-19.03",
|
||||
"uri": "github:edolstra/nixpkgs/9a593b575e4044f9aff939b512e7cb1cf1e76a65"
|
||||
"originalUrl": "nixpkgs/release-19.03",
|
||||
"url": "github:edolstra/nixpkgs/9a593b575e4044f9aff939b512e7cb1cf1e76a65"
|
||||
}
|
||||
},
|
||||
"version": 3
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
edition = 201909;
|
||||
|
||||
inputs.nixpkgs.uri = "nixpkgs/release-19.03";
|
||||
inputs.nixpkgs.url = "nixpkgs/release-19.03";
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -19,21 +19,21 @@ using namespace nix::flake;
|
|||
|
||||
class FlakeCommand : virtual Args, public EvalCommand, public MixFlakeOptions
|
||||
{
|
||||
std::string flakeUri = ".";
|
||||
std::string flakeUrl = ".";
|
||||
|
||||
public:
|
||||
|
||||
FlakeCommand()
|
||||
{
|
||||
expectArg("flake-uri", &flakeUri, true);
|
||||
expectArg("flake-url", &flakeUrl, true);
|
||||
}
|
||||
|
||||
FlakeRef getFlakeRef()
|
||||
{
|
||||
if (flakeUri.find('/') != std::string::npos || flakeUri == ".")
|
||||
return FlakeRef(flakeUri, true);
|
||||
if (flakeUrl.find('/') != std::string::npos || flakeUrl == ".")
|
||||
return FlakeRef(flakeUrl, true);
|
||||
else
|
||||
return FlakeRef(flakeUri);
|
||||
return FlakeRef(flakeUrl);
|
||||
}
|
||||
|
||||
Flake getFlake()
|
||||
|
@ -74,7 +74,7 @@ struct CmdFlakeList : EvalCommand
|
|||
|
||||
static void printSourceInfo(const SourceInfo & sourceInfo)
|
||||
{
|
||||
std::cout << fmt("URI: %s\n", sourceInfo.resolvedRef.to_string());
|
||||
std::cout << fmt("URL: %s\n", sourceInfo.resolvedRef.to_string());
|
||||
if (sourceInfo.resolvedRef.ref)
|
||||
std::cout << fmt("Branch: %s\n",*sourceInfo.resolvedRef.ref);
|
||||
if (sourceInfo.resolvedRef.rev)
|
||||
|
@ -89,7 +89,7 @@ static void printSourceInfo(const SourceInfo & sourceInfo)
|
|||
|
||||
static void sourceInfoToJson(const SourceInfo & sourceInfo, nlohmann::json & j)
|
||||
{
|
||||
j["uri"] = sourceInfo.resolvedRef.to_string();
|
||||
j["url"] = sourceInfo.resolvedRef.to_string();
|
||||
if (sourceInfo.resolvedRef.ref)
|
||||
j["branch"] = *sourceInfo.resolvedRef.ref;
|
||||
if (sourceInfo.resolvedRef.rev)
|
||||
|
@ -454,7 +454,7 @@ struct CmdFlakeCheck : FlakeCommand, MixJSON
|
|||
struct CmdFlakeAdd : MixEvalArgs, Command
|
||||
{
|
||||
FlakeUri alias;
|
||||
FlakeUri uri;
|
||||
FlakeUri url;
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
|
@ -464,7 +464,7 @@ struct CmdFlakeAdd : MixEvalArgs, Command
|
|||
CmdFlakeAdd()
|
||||
{
|
||||
expectArg("alias", &alias);
|
||||
expectArg("flake-uri", &uri);
|
||||
expectArg("flake-url", &url);
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
@ -473,7 +473,7 @@ struct CmdFlakeAdd : MixEvalArgs, Command
|
|||
Path userRegistryPath = getUserRegistryPath();
|
||||
auto userRegistry = readRegistry(userRegistryPath);
|
||||
userRegistry->entries.erase(aliasRef);
|
||||
userRegistry->entries.insert_or_assign(aliasRef, FlakeRef(uri));
|
||||
userRegistry->entries.insert_or_assign(aliasRef, FlakeRef(url));
|
||||
writeRegistry(*userRegistry, userRegistryPath);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -89,19 +89,19 @@ cat > $registry <<EOF
|
|||
{
|
||||
"flakes": {
|
||||
"flake1": {
|
||||
"uri": "file://$flake1Dir"
|
||||
"url": "file://$flake1Dir"
|
||||
},
|
||||
"flake2": {
|
||||
"uri": "file://$flake2Dir"
|
||||
"url": "file://$flake2Dir"
|
||||
},
|
||||
"flake3": {
|
||||
"uri": "file://$flake3Dir"
|
||||
"url": "file://$flake3Dir"
|
||||
},
|
||||
"flake4": {
|
||||
"uri": "flake3"
|
||||
"url": "flake3"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"uri": "flake1"
|
||||
"url": "flake1"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
|
@ -112,12 +112,12 @@ EOF
|
|||
(( $(nix flake list --flake-registry $registry | wc -l) == 5 ))
|
||||
|
||||
# Test 'nix flake info'.
|
||||
nix flake info --flake-registry $registry flake1 | grep -q 'URI: .*flake1.*'
|
||||
nix flake info --flake-registry $registry flake1 | grep -q 'URL: .*flake1.*'
|
||||
|
||||
# Test 'nix flake info' on a local flake.
|
||||
(cd $flake1Dir && nix flake info --flake-registry $registry) | grep -q 'URI: .*flake1.*'
|
||||
(cd $flake1Dir && nix flake info --flake-registry $registry .) | grep -q 'URI: .*flake1.*'
|
||||
nix flake info --flake-registry $registry $flake1Dir | grep -q 'URI: .*flake1.*'
|
||||
(cd $flake1Dir && nix flake info --flake-registry $registry) | grep -q 'URL: .*flake1.*'
|
||||
(cd $flake1Dir && nix flake info --flake-registry $registry .) | grep -q 'URL: .*flake1.*'
|
||||
nix flake info --flake-registry $registry $flake1Dir | grep -q 'URL: .*flake1.*'
|
||||
|
||||
# Test 'nix flake info --json'.
|
||||
json=$(nix flake info --flake-registry $registry flake1 --json | jq .)
|
||||
|
@ -234,7 +234,7 @@ cat > $flake3Dir/flake.nix <<EOF
|
|||
flake1 = {};
|
||||
flake2 = {};
|
||||
nonFlake = {
|
||||
uri = "$nonFlakeDir";
|
||||
url = "$nonFlakeDir";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
@ -299,7 +299,7 @@ cat > $flake3Dir/flake.nix <<EOF
|
|||
|
||||
inputs = {
|
||||
nonFlake = {
|
||||
uri = "$nonFlakeDir";
|
||||
url = "$nonFlakeDir";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue