1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 06:01:48 +02:00

Remove flake 'edition' field

Future editions of flakes or the Nix language can be supported by
renaming flake.nix (e.g. flake-v2.nix). This avoids a bootstrap
problem where we don't know which grammar to use to parse
flake*.nix. It also allows a project to support multiple flake
editions, in theory.
This commit is contained in:
Eelco Dolstra 2020-04-10 10:24:09 +02:00
parent 3aaceeb7e2
commit e5ea01c1a8
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
7 changed files with 6 additions and 64 deletions

View file

@ -19,7 +19,6 @@ let
result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; };
in
if node.flake or true then
assert flake.edition or flake.epoch or 0 == 201909;
assert builtins.isFunction flake.outputs;
result
else

View file

@ -231,22 +231,14 @@ static Flake getFlake(
expectType(state, tAttrs, vInfo, Pos(state.symbols.create(flakeFile), 0, 0));
auto sEdition = state.symbols.create("edition");
auto sEdition = state.symbols.create("edition"); // FIXME: remove soon
auto sEpoch = state.symbols.create("epoch"); // FIXME: remove soon
auto edition = vInfo.attrs->get(sEdition);
if (!edition)
edition = vInfo.attrs->get(sEpoch);
if (vInfo.attrs->get(sEdition))
warn("flake '%s' has deprecated attribution 'edition'", lockedRef);
if (edition) {
expectType(state, tInt, *edition->value, *edition->pos);
flake.edition = edition->value->integer;
if (flake.edition > 201909)
throw Error("flake '%s' requires unsupported edition %d; please upgrade Nix", lockedRef, flake.edition);
if (flake.edition < 201909)
throw Error("flake '%s' has illegal edition %d", lockedRef, flake.edition);
} else
throw Error("flake '%s' lacks attribute 'edition'", lockedRef);
if (vInfo.attrs->get(sEpoch))
warn("flake '%s' has deprecated attribution 'epoch'", lockedRef);
if (auto description = vInfo.attrs->get(state.sDescription)) {
expectType(state, tString, *description->value, *description->pos);

View file

@ -34,7 +34,6 @@ struct Flake
std::shared_ptr<const fetchers::Tree> sourceInfo;
FlakeInputs inputs;
Value * vOutputs; // FIXME: gc
unsigned int edition;
~Flake();
};

View file

@ -1,8 +1,6 @@
{
description = "A flake for building Hello World";
edition = 201909;
outputs = { self, nixpkgs }: {
packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;

View file

@ -82,7 +82,6 @@ static void printFlakeInfo(const Store & store, const Flake & flake)
{
std::cout << fmt("Resolved URL: %s\n", flake.resolvedRef.to_string());
std::cout << fmt("Locked URL: %s\n", flake.lockedRef.to_string());
std::cout << fmt("Edition: %s\n", flake.edition);
if (flake.description)
std::cout << fmt("Description: %s\n", *flake.description);
std::cout << fmt("Path: %s\n", store.printStorePath(flake.sourceInfo->storePath));
@ -100,7 +99,6 @@ static nlohmann::json flakeToJson(const Store & store, const Flake & flake)
nlohmann::json j;
if (flake.description)
j["description"] = *flake.description;
j["edition"] = flake.edition;
j["originalUrl"] = flake.originalRef.to_string();
j["original"] = attrsToJson(flake.originalRef.toAttrs());
j["resolvedUrl"] = flake.resolvedRef.to_string();