forked from lix-project/lix
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:
parent
3aaceeb7e2
commit
e5ea01c1a8
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
description = "The purely functional package manager";
|
||||
|
||||
edition = 201909;
|
||||
edition = 201909; # FIXME: remove
|
||||
|
||||
inputs.nixpkgs.uri = "nixpkgs/nixos-20.03-small";
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -34,7 +34,6 @@ struct Flake
|
|||
std::shared_ptr<const fetchers::Tree> sourceInfo;
|
||||
FlakeInputs inputs;
|
||||
Value * vOutputs; // FIXME: gc
|
||||
unsigned int edition;
|
||||
~Flake();
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -35,8 +35,6 @@ done
|
|||
|
||||
cat > $flake1Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
description = "Bla bla";
|
||||
|
||||
outputs = inputs: rec {
|
||||
|
@ -55,8 +53,6 @@ git -C $flake1Dir commit -m 'Initial'
|
|||
|
||||
cat > $flake2Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
description = "Fnord";
|
||||
|
||||
outputs = { self, flake1 }: rec {
|
||||
|
@ -70,8 +66,6 @@ git -C $flake2Dir commit -m 'Initial'
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
description = "Fnord";
|
||||
|
||||
outputs = { self, flake2 }: rec {
|
||||
|
@ -246,8 +240,6 @@ rm $flake3Dir/flake.nix
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
description = "Fnord";
|
||||
|
||||
outputs = { self, flake1, flake2 }: rec {
|
||||
|
@ -271,10 +263,6 @@ git -C $flake3Dir add flake.lock
|
|||
|
||||
git -C $flake3Dir commit -m 'Add lockfile'
|
||||
|
||||
# Unsupported editions should be an error.
|
||||
sed -i $flake3Dir/flake.nix -e s/201909/201912/
|
||||
nix build -o $TEST_ROOT/result $flake3Dir#sth 2>&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 <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
inputs = {
|
||||
flake1 = {};
|
||||
flake2 = {};
|
||||
|
@ -370,8 +356,6 @@ rm $flake3Dir/flake.nix
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
inputs = {
|
||||
nonFlake = {
|
||||
url = "$nonFlakeDir";
|
||||
|
@ -428,8 +412,6 @@ nix flake clone flake1 --dest $TEST_ROOT/flake1-v2
|
|||
# More 'nix flake check' tests.
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
outputs = { flake1, self }: {
|
||||
overlay = final: prev: {
|
||||
};
|
||||
|
@ -441,8 +423,6 @@ nix flake check $flake3Dir
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
outputs = { flake1, self }: {
|
||||
overlay = finalll: prev: {
|
||||
};
|
||||
|
@ -454,8 +434,6 @@ EOF
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
outputs = { flake1, self }: {
|
||||
nixosModules.foo = {
|
||||
a.b.c = 123;
|
||||
|
@ -469,8 +447,6 @@ nix flake check $flake3Dir
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
outputs = { flake1, self }: {
|
||||
nixosModules.foo = {
|
||||
a.b.c = 123;
|
||||
|
@ -484,8 +460,6 @@ EOF
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
outputs = { flake1, self }: {
|
||||
nixosModule = { config, pkgs, ... }: {
|
||||
a.b.c = 123;
|
||||
|
@ -498,8 +472,6 @@ nix flake check $flake3Dir
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
outputs = { flake1, self }: {
|
||||
nixosModule = { config, pkgs }: {
|
||||
a.b.c = 123;
|
||||
|
@ -513,8 +485,6 @@ EOF
|
|||
# Test 'follows' inputs.
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
inputs.foo = {
|
||||
type = "indirect";
|
||||
id = "flake1";
|
||||
|
@ -531,8 +501,6 @@ nix flake update $flake3Dir
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
inputs.bar.follows = "flake2/flake1";
|
||||
|
||||
outputs = { self, flake2, bar }: {
|
||||
|
@ -545,8 +513,6 @@ nix flake update $flake3Dir
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
inputs.bar.follows = "flake2";
|
||||
|
||||
outputs = { self, flake2, bar }: {
|
||||
|
@ -560,8 +526,6 @@ nix flake update $flake3Dir
|
|||
# Test overriding inputs of inputs.
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
inputs.flake2.inputs.flake1 = {
|
||||
type = "git";
|
||||
url = file://$flake7Dir;
|
||||
|
@ -577,8 +541,6 @@ nix flake update $flake3Dir
|
|||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
inputs.flake2.inputs.flake1.follows = "foo";
|
||||
inputs.foo.url = git+file://$flake7Dir;
|
||||
|
||||
|
@ -596,8 +558,6 @@ hg init $flake5Dir
|
|||
|
||||
cat > $flake5Dir/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
outputs = { self, flake1 }: {
|
||||
defaultPackage.$system = flake1.defaultPackage.$system;
|
||||
|
||||
|
@ -669,8 +629,6 @@ nix flake list-inputs $flake3Dir --json | jq .
|
|||
# Test circular flake dependencies.
|
||||
cat > $flakeA/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
inputs.b.url = git+file://$flakeB;
|
||||
inputs.b.inputs.a.follows = "/";
|
||||
|
||||
|
@ -685,8 +643,6 @@ git -C $flakeA add flake.nix
|
|||
|
||||
cat > $flakeB/flake.nix <<EOF
|
||||
{
|
||||
edition = 201909;
|
||||
|
||||
inputs.a.url = git+file://$flakeA;
|
||||
|
||||
outputs = { self, nixpkgs, a }: {
|
||||
|
|
Loading…
Reference in a new issue