aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-07-11 13:54:53 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-07-11 13:54:53 +0200
commitad42a784690449873fccb20192bd2150da81c56d (patch)
treeff61b5a0416ff45a74d02301da549ae1f5df5ebf /src
parent4205234f26211baa787fd18de0256622759fea8a (diff)
Rename 'epoch' -> 'edition'
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/flake/flake.cc26
-rw-r--r--src/libexpr/flake/flake.hh2
-rw-r--r--src/nix/flake.cc4
3 files changed, 19 insertions, 13 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 4f59c61bd..8b9525680 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -223,16 +223,21 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef)
state.forceAttrs(vInfo);
- auto sEpoch = state.symbols.create("epoch");
-
- if (auto epoch = vInfo.attrs->get(sEpoch)) {
- flake.epoch = state.forceInt(*(**epoch).value, *(**epoch).pos);
- if (flake.epoch < 201906)
- throw Error("flake '%s' has illegal epoch %d", flakeRef, flake.epoch);
- if (flake.epoch > 201906)
- throw Error("flake '%s' requires unsupported epoch %d; please upgrade Nix", flakeRef, flake.epoch);
+ auto sEdition = state.symbols.create("edition");
+ auto sEpoch = state.symbols.create("epoch"); // FIXME: remove soon
+
+ auto edition = vInfo.attrs->get(sEdition);
+ if (!edition)
+ edition = vInfo.attrs->get(sEpoch);
+
+ if (edition) {
+ flake.edition = state.forceInt(*(**edition).value, *(**edition).pos);
+ if (flake.edition < 201906)
+ throw Error("flake '%s' has illegal edition %d", flakeRef, flake.edition);
+ if (flake.edition > 201906)
+ throw Error("flake '%s' requires unsupported edition %d; please upgrade Nix", flakeRef, flake.edition);
} else
- throw Error("flake '%s' lacks attribute 'epoch'", flakeRef);
+ throw Error("flake '%s' lacks attribute 'edition'", flakeRef);
if (auto name = vInfo.attrs->get(state.sName))
flake.id = state.forceStringNoCtx(*(**name).value, *(**name).pos);
@@ -271,7 +276,8 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef)
throw Error("flake '%s' lacks attribute 'outputs'", flakeRef);
for (auto & attr : *vInfo.attrs) {
- if (attr.name != sEpoch &&
+ if (attr.name != sEdition &&
+ attr.name != sEpoch &&
attr.name != state.sName &&
attr.name != state.sDescription &&
attr.name != sInputs &&
diff --git a/src/libexpr/flake/flake.hh b/src/libexpr/flake/flake.hh
index de0feb2c4..01fb421bd 100644
--- a/src/libexpr/flake/flake.hh
+++ b/src/libexpr/flake/flake.hh
@@ -67,7 +67,7 @@ struct Flake
std::vector<FlakeRef> inputs;
std::map<FlakeAlias, FlakeRef> nonFlakeInputs;
Value * vOutputs; // FIXME: gc
- unsigned int epoch;
+ unsigned int edition;
Flake(const FlakeRef & origRef, const SourceInfo & sourceInfo)
: originalRef(origRef), sourceInfo(sourceInfo) {};
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 49f7c33c7..aab29b626 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -105,7 +105,7 @@ static void printFlakeInfo(const Flake & flake)
{
std::cout << fmt("ID: %s\n", flake.id);
std::cout << fmt("Description: %s\n", flake.description);
- std::cout << fmt("Epoch: %s\n", flake.epoch);
+ std::cout << fmt("Edition: %s\n", flake.edition);
printSourceInfo(flake.sourceInfo);
}
@@ -114,7 +114,7 @@ static nlohmann::json flakeToJson(const Flake & flake)
nlohmann::json j;
j["id"] = flake.id;
j["description"] = flake.description;
- j["epoch"] = flake.epoch;
+ j["edition"] = flake.edition;
sourceInfoToJson(flake.sourceInfo, j);
return j;
}