diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-04-01 14:38:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-01 14:38:32 +0200 |
commit | bf4895961d0869d75fe2fd9ac18887a1daea957e (patch) | |
tree | 7c13b8d7e0d915ea672d146c1c29501c4b900cb1 | |
parent | c74eac9fdeb172ea155b2d7ee9fe68d6487adc39 (diff) | |
parent | 50f9f335c92a88e8c9bd3421e6befbcd06cac4ec (diff) |
Merge pull request #6344 from flox/profile_url_uri
profile!: consistent use of url/uri. create new version
-rw-r--r-- | src/nix/profile.cc | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/nix/profile.cc b/src/nix/profile.cc index f35947ddb..b151e48d6 100644 --- a/src/nix/profile.cc +++ b/src/nix/profile.cc @@ -97,19 +97,30 @@ struct ProfileManifest auto json = nlohmann::json::parse(readFile(manifestPath)); auto version = json.value("version", 0); - if (version != 1) - throw Error("profile manifest '%s' has unsupported version %d", manifestPath, version); + 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); + } for (auto & e : json["elements"]) { ProfileElement element; for (auto & p : e["storePaths"]) element.storePaths.insert(state.store->parseStorePath((std::string) p)); element.active = e["active"]; - if (e.value("uri", "") != "") { - auto originalUrl = e.value("originalUrl", e["originalUri"]); + if (e.value(sUrl,"") != "") { element.source = ProfileElementSource{ - parseFlakeRef(originalUrl), - parseFlakeRef(e["uri"]), + parseFlakeRef(e[sOriginalUrl]), + parseFlakeRef(e[sUrl]), e["attrPath"] }; } @@ -144,13 +155,13 @@ struct ProfileManifest obj["active"] = element.active; if (element.source) { 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; } array.push_back(obj); } nlohmann::json json; - json["version"] = 1; + json["version"] = 2; json["elements"] = array; return json.dump(); } |