aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-09-20 14:46:37 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-09-20 14:46:37 +0200
commit5961c9409739751caaea54540607703c53c9a37e (patch)
tree87b450106cae004ba6a1736369706a6886f76cfc /src/libexpr
parent68e0f23edc7622290809c81f5071c9f99aded459 (diff)
Flake alias -> id
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/flake/flakeref.cc12
-rw-r--r--src/libexpr/flake/flakeref.hh13
2 files changed, 12 insertions, 13 deletions
diff --git a/src/libexpr/flake/flakeref.cc b/src/libexpr/flake/flakeref.cc
index 4930d03ce..364a98358 100644
--- a/src/libexpr/flake/flakeref.cc
+++ b/src/libexpr/flake/flakeref.cc
@@ -20,7 +20,7 @@ const static std::string revOrRefRegex = "(?:(" + revRegexS + ")|(" + refRegex +
// "master/e72daba8250068216d79d2aeef40d4d95aff6666").
const static std::string refAndOrRevRegex = "(?:(" + revRegexS + ")|(?:(" + refRegex + ")(?:/(" + revRegexS + "))?))";
-const static std::string flakeAlias = "[a-zA-Z][a-zA-Z0-9_-]*";
+const static std::string flakeId = "[a-zA-Z][a-zA-Z0-9_-]*";
// GitHub references.
const static std::string ownerRegex = "[a-zA-Z][a-zA-Z0-9_-]*";
@@ -43,7 +43,7 @@ FlakeRef::FlakeRef(const std::string & uri_, bool allowRelative)
// FIXME: could combine this into one regex.
static std::regex flakeRegex(
- "(?:flake:)?(" + flakeAlias + ")(?:/(?:" + refAndOrRevRegex + "))?",
+ "(?:flake:)?(" + flakeId + ")(?:/(?:" + refAndOrRevRegex + "))?",
std::regex::ECMAScript);
static std::regex githubRegex(
@@ -90,8 +90,8 @@ FlakeRef::FlakeRef(const std::string & uri_, bool allowRelative)
std::cmatch match;
if (std::regex_match(uri.c_str(), match, flakeRegex)) {
- IsAlias d;
- d.alias = match[1];
+ IsId d;
+ d.id = match[1];
if (match[2].matched)
rev = Hash(match[2], htSHA1);
else if (match[3].matched) {
@@ -195,8 +195,8 @@ std::string FlakeRef::to_string() const
string += value; // FIXME: escaping
};
- if (auto refData = std::get_if<FlakeRef::IsAlias>(&data)) {
- string = refData->alias;
+ if (auto refData = std::get_if<FlakeRef::IsId>(&data)) {
+ string = refData->id;
if (ref) string += '/' + *ref;
if (rev) string += '/' + rev->gitRev();
}
diff --git a/src/libexpr/flake/flakeref.hh b/src/libexpr/flake/flakeref.hh
index 39e019dbd..addf5449f 100644
--- a/src/libexpr/flake/flakeref.hh
+++ b/src/libexpr/flake/flakeref.hh
@@ -101,16 +101,15 @@ namespace nix {
*/
typedef std::string FlakeId;
-typedef std::string FlakeAlias;
typedef std::string FlakeUri;
struct FlakeRef
{
- struct IsAlias
+ struct IsId
{
- FlakeAlias alias;
- bool operator<(const IsAlias & b) const { return alias < b.alias; };
- bool operator==(const IsAlias & b) const { return alias == b.alias; };
+ FlakeId id;
+ bool operator<(const IsId & b) const { return id < b.id; };
+ bool operator==(const IsId & b) const { return id == b.id; };
};
struct IsGitHub {
@@ -140,7 +139,7 @@ struct FlakeRef
// Git, Tarball
- std::variant<IsAlias, IsGitHub, IsGit, IsPath> data;
+ std::variant<IsId, IsGitHub, IsGit, IsPath> data;
std::optional<std::string> ref;
std::optional<Hash> rev;
@@ -168,7 +167,7 @@ struct FlakeRef
a flake ID, which requires a lookup in the flake registry. */
bool isDirect() const
{
- return !std::get_if<FlakeRef::IsAlias>(&data);
+ return !std::get_if<FlakeRef::IsId>(&data);
}
/* Check whether this is an "immutable" flake reference, that is,