forked from lix-project/lix
Rename 'epoch' -> 'edition'
This commit is contained in:
parent
4205234f26
commit
ad42a78469
|
@ -65,7 +65,7 @@ Upcoming but not yet implemented:
|
||||||
NixOS configuration can be reproduced unambiguously from the top-level flake.
|
NixOS configuration can be reproduced unambiguously from the top-level flake.
|
||||||
|
|
||||||
* Nix code can query flake metadata such as `commitHash` (the Git revision) or
|
* Nix code can query flake metadata such as `commitHash` (the Git revision) or
|
||||||
`epoch` (the date of the last commit). This is useful for NixOS to compute
|
`edition` (the date of the last commit). This is useful for NixOS to compute
|
||||||
the NixOS version string (which will be the revision of the top-level
|
the NixOS version string (which will be the revision of the top-level
|
||||||
configuration flake, uniquely identifying the configuration).
|
configuration flake, uniquely identifying the configuration).
|
||||||
|
|
||||||
|
@ -85,9 +85,9 @@ repository that provides a single package and a single NixOS module.
|
||||||
# The flake identifier.
|
# The flake identifier.
|
||||||
name = "dwarffs";
|
name = "dwarffs";
|
||||||
|
|
||||||
# The epoch may be used in the future to determine how Nix
|
# The edition may be used in the future to determine how Nix
|
||||||
# expressions inside this flake are to be parsed.
|
# expressions inside this flake are to be parsed.
|
||||||
epoch = 201906;
|
edition = 201906;
|
||||||
|
|
||||||
# Some other metadata.
|
# Some other metadata.
|
||||||
description = "A filesystem that fetches DWARF debug info from the Internet on demand";
|
description = "A filesystem that fetches DWARF debug info from the Internet on demand";
|
||||||
|
@ -162,7 +162,7 @@ Similarly, a minimal `flake.nix` for Nixpkgs:
|
||||||
{
|
{
|
||||||
name = "nixpkgs";
|
name = "nixpkgs";
|
||||||
|
|
||||||
epoch = 201906;
|
edition = 201906;
|
||||||
|
|
||||||
description = "A collection of packages for the Nix package manager";
|
description = "A collection of packages for the Nix package manager";
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ flakes in (local) Git repositories.
|
||||||
{
|
{
|
||||||
name = "my-system";
|
name = "my-system";
|
||||||
|
|
||||||
epoch = 201906;
|
edition = 201906;
|
||||||
|
|
||||||
inputs =
|
inputs =
|
||||||
[ "nixpkgs/nixos-18.09"
|
[ "nixpkgs/nixos-18.09"
|
||||||
|
|
|
@ -223,16 +223,21 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef)
|
||||||
|
|
||||||
state.forceAttrs(vInfo);
|
state.forceAttrs(vInfo);
|
||||||
|
|
||||||
auto sEpoch = state.symbols.create("epoch");
|
auto sEdition = state.symbols.create("edition");
|
||||||
|
auto sEpoch = state.symbols.create("epoch"); // FIXME: remove soon
|
||||||
|
|
||||||
if (auto epoch = vInfo.attrs->get(sEpoch)) {
|
auto edition = vInfo.attrs->get(sEdition);
|
||||||
flake.epoch = state.forceInt(*(**epoch).value, *(**epoch).pos);
|
if (!edition)
|
||||||
if (flake.epoch < 201906)
|
edition = vInfo.attrs->get(sEpoch);
|
||||||
throw Error("flake '%s' has illegal epoch %d", flakeRef, flake.epoch);
|
|
||||||
if (flake.epoch > 201906)
|
if (edition) {
|
||||||
throw Error("flake '%s' requires unsupported epoch %d; please upgrade Nix", flakeRef, flake.epoch);
|
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
|
} 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))
|
if (auto name = vInfo.attrs->get(state.sName))
|
||||||
flake.id = state.forceStringNoCtx(*(**name).value, *(**name).pos);
|
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);
|
throw Error("flake '%s' lacks attribute 'outputs'", flakeRef);
|
||||||
|
|
||||||
for (auto & attr : *vInfo.attrs) {
|
for (auto & attr : *vInfo.attrs) {
|
||||||
if (attr.name != sEpoch &&
|
if (attr.name != sEdition &&
|
||||||
|
attr.name != sEpoch &&
|
||||||
attr.name != state.sName &&
|
attr.name != state.sName &&
|
||||||
attr.name != state.sDescription &&
|
attr.name != state.sDescription &&
|
||||||
attr.name != sInputs &&
|
attr.name != sInputs &&
|
||||||
|
|
|
@ -67,7 +67,7 @@ struct Flake
|
||||||
std::vector<FlakeRef> inputs;
|
std::vector<FlakeRef> inputs;
|
||||||
std::map<FlakeAlias, FlakeRef> nonFlakeInputs;
|
std::map<FlakeAlias, FlakeRef> nonFlakeInputs;
|
||||||
Value * vOutputs; // FIXME: gc
|
Value * vOutputs; // FIXME: gc
|
||||||
unsigned int epoch;
|
unsigned int edition;
|
||||||
|
|
||||||
Flake(const FlakeRef & origRef, const SourceInfo & sourceInfo)
|
Flake(const FlakeRef & origRef, const SourceInfo & sourceInfo)
|
||||||
: originalRef(origRef), sourceInfo(sourceInfo) {};
|
: originalRef(origRef), sourceInfo(sourceInfo) {};
|
||||||
|
|
|
@ -105,7 +105,7 @@ static void printFlakeInfo(const Flake & flake)
|
||||||
{
|
{
|
||||||
std::cout << fmt("ID: %s\n", flake.id);
|
std::cout << fmt("ID: %s\n", flake.id);
|
||||||
std::cout << fmt("Description: %s\n", flake.description);
|
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);
|
printSourceInfo(flake.sourceInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ static nlohmann::json flakeToJson(const Flake & flake)
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
j["id"] = flake.id;
|
j["id"] = flake.id;
|
||||||
j["description"] = flake.description;
|
j["description"] = flake.description;
|
||||||
j["epoch"] = flake.epoch;
|
j["edition"] = flake.edition;
|
||||||
sourceInfoToJson(flake.sourceInfo, j);
|
sourceInfoToJson(flake.sourceInfo, j);
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue