mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +02:00
Merge pull request #6344 from flox/profile_url_uri
profile!: consistent use of url/uri. create new version
This commit is contained in:
commit
bf4895961d
1 changed files with 19 additions and 8 deletions
|
@ -97,19 +97,30 @@ struct ProfileManifest
|
||||||
auto json = nlohmann::json::parse(readFile(manifestPath));
|
auto json = nlohmann::json::parse(readFile(manifestPath));
|
||||||
|
|
||||||
auto version = json.value("version", 0);
|
auto version = json.value("version", 0);
|
||||||
if (version != 1)
|
std::string sUrl;
|
||||||
|
std::string sOriginalUrl;
|
||||||
|
switch(version){
|
||||||
|
case 1:
|
||||||
|
sUrl = "uri";
|
||||||
|
sOriginalUrl = "originalUri";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
sUrl = "url";
|
||||||
|
sOriginalUrl = "originalUrl";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
throw Error("profile manifest '%s' has unsupported version %d", manifestPath, version);
|
throw Error("profile manifest '%s' has unsupported version %d", manifestPath, version);
|
||||||
|
}
|
||||||
|
|
||||||
for (auto & e : json["elements"]) {
|
for (auto & e : json["elements"]) {
|
||||||
ProfileElement element;
|
ProfileElement element;
|
||||||
for (auto & p : e["storePaths"])
|
for (auto & p : e["storePaths"])
|
||||||
element.storePaths.insert(state.store->parseStorePath((std::string) p));
|
element.storePaths.insert(state.store->parseStorePath((std::string) p));
|
||||||
element.active = e["active"];
|
element.active = e["active"];
|
||||||
if (e.value("uri", "") != "") {
|
if (e.value(sUrl,"") != "") {
|
||||||
auto originalUrl = e.value("originalUrl", e["originalUri"]);
|
|
||||||
element.source = ProfileElementSource{
|
element.source = ProfileElementSource{
|
||||||
parseFlakeRef(originalUrl),
|
parseFlakeRef(e[sOriginalUrl]),
|
||||||
parseFlakeRef(e["uri"]),
|
parseFlakeRef(e[sUrl]),
|
||||||
e["attrPath"]
|
e["attrPath"]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -144,13 +155,13 @@ struct ProfileManifest
|
||||||
obj["active"] = element.active;
|
obj["active"] = element.active;
|
||||||
if (element.source) {
|
if (element.source) {
|
||||||
obj["originalUrl"] = element.source->originalRef.to_string();
|
obj["originalUrl"] = element.source->originalRef.to_string();
|
||||||
obj["uri"] = element.source->resolvedRef.to_string();
|
obj["url"] = element.source->resolvedRef.to_string();
|
||||||
obj["attrPath"] = element.source->attrPath;
|
obj["attrPath"] = element.source->attrPath;
|
||||||
}
|
}
|
||||||
array.push_back(obj);
|
array.push_back(obj);
|
||||||
}
|
}
|
||||||
nlohmann::json json;
|
nlohmann::json json;
|
||||||
json["version"] = 1;
|
json["version"] = 2;
|
||||||
json["elements"] = array;
|
json["elements"] = array;
|
||||||
return json.dump();
|
return json.dump();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue