From e5ea01c1a8bbd328dcc576928bf3e4271cb55399 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 10 Apr 2020 10:24:09 +0200 Subject: [PATCH] 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. --- flake.nix | 2 +- src/libexpr/flake/call-flake.nix | 1 - src/libexpr/flake/flake.cc | 18 ++++--------- src/libexpr/flake/flake.hh | 1 - src/nix/flake-template.nix | 2 -- src/nix/flake.cc | 2 -- tests/flakes.sh | 44 -------------------------------- 7 files changed, 6 insertions(+), 64 deletions(-) diff --git a/flake.nix b/flake.nix index ffd8b5b9a..16df0833b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,7 @@ { description = "The purely functional package manager"; - edition = 201909; + edition = 201909; # FIXME: remove inputs.nixpkgs.uri = "nixpkgs/nixos-20.03-small"; diff --git a/src/libexpr/flake/call-flake.nix b/src/libexpr/flake/call-flake.nix index dc9ed357c..8ee17b8f4 100644 --- a/src/libexpr/flake/call-flake.nix +++ b/src/libexpr/flake/call-flake.nix @@ -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 diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 86bb05b5d..212eceeac 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -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); diff --git a/src/libexpr/flake/flake.hh b/src/libexpr/flake/flake.hh index 7ee9bbe76..107498c1b 100644 --- a/src/libexpr/flake/flake.hh +++ b/src/libexpr/flake/flake.hh @@ -34,7 +34,6 @@ struct Flake std::shared_ptr sourceInfo; FlakeInputs inputs; Value * vOutputs; // FIXME: gc - unsigned int edition; ~Flake(); }; diff --git a/src/nix/flake-template.nix b/src/nix/flake-template.nix index 321961013..60d7171f3 100644 --- a/src/nix/flake-template.nix +++ b/src/nix/flake-template.nix @@ -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; diff --git a/src/nix/flake.cc b/src/nix/flake.cc index e79f4129a..e8ca0fd03 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -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(); diff --git a/tests/flakes.sh b/tests/flakes.sh index 050dbf127..1b234c992 100644 --- a/tests/flakes.sh +++ b/tests/flakes.sh @@ -35,8 +35,6 @@ done cat > $flake1Dir/flake.nix < $flake2Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix <&1 | grep 'unsupported edition' - # Test whether registry caching works. nix flake list --flake-registry file://$registry | grep -q flake3 mv $registry $registry.tmp @@ -300,8 +288,6 @@ rm $flake3Dir/flake.nix cat > $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake3Dir/flake.nix < $flake5Dir/flake.nix < $flakeA/flake.nix < $flakeB/flake.nix <