forked from lix-project/lix
commit
55a0451e51
4 changed files with 18 additions and 4 deletions
|
@ -309,10 +309,17 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef, bool impureIsAllowe
|
|||
|
||||
state.forceAttrs(vInfo);
|
||||
|
||||
if (auto epoch = vInfo.attrs->get(state.symbols.create("epoch"))) {
|
||||
flake.epoch = state.forceInt(*(**epoch).value, *(**epoch).pos);
|
||||
if (flake.epoch > 2019)
|
||||
throw Error("flake '%s' requires unsupported epoch %d; please upgrade Nix", flakeRef, flake.epoch);
|
||||
} else
|
||||
throw Error("flake '%s' lacks attribute 'epoch'", flakeRef);
|
||||
|
||||
if (auto name = vInfo.attrs->get(state.sName))
|
||||
flake.id = state.forceStringNoCtx(*(**name).value, *(**name).pos);
|
||||
else
|
||||
throw Error("flake lacks attribute 'name'");
|
||||
throw Error("flake '%s' lacks attribute 'name'", flakeRef);
|
||||
|
||||
if (auto description = vInfo.attrs->get(state.sDescription))
|
||||
flake.description = state.forceStringNoCtx(*(**description).value, *(**description).pos);
|
||||
|
@ -337,7 +344,7 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef, bool impureIsAllowe
|
|||
state.forceFunction(*(**provides).value, *(**provides).pos);
|
||||
flake.vProvides = (**provides).value;
|
||||
} else
|
||||
throw Error("flake lacks attribute 'provides'");
|
||||
throw Error("flake '%s' lacks attribute 'provides'", flakeRef);
|
||||
|
||||
return flake;
|
||||
}
|
||||
|
|
|
@ -101,7 +101,8 @@ struct Flake
|
|||
std::map<FlakeAlias, FlakeRef> nonFlakeRequires;
|
||||
Value * vProvides; // FIXME: gc
|
||||
// date
|
||||
// content hash
|
||||
unsigned int epoch;
|
||||
|
||||
Flake(const FlakeRef & origRef, const SourceInfo & sourceInfo) : originalRef(origRef),
|
||||
resolvedRef(sourceInfo.resolvedRef), revCount(sourceInfo.revCount), storePath(sourceInfo.storePath) {};
|
||||
};
|
||||
|
|
|
@ -83,6 +83,7 @@ void printFlakeInfo(const Flake & flake, bool json) {
|
|||
if (flake.revCount)
|
||||
j["revCount"] = *flake.revCount;
|
||||
j["path"] = flake.storePath;
|
||||
j["epoch"] = flake.epoch;
|
||||
std::cout << j.dump(4) << std::endl;
|
||||
} else {
|
||||
std::cout << "ID: " << flake.id << "\n";
|
||||
|
@ -95,6 +96,7 @@ void printFlakeInfo(const Flake & flake, bool json) {
|
|||
if (flake.revCount)
|
||||
std::cout << "Revcount: " << *flake.revCount << "\n";
|
||||
std::cout << "Path: " << flake.storePath << "\n";
|
||||
std::cout << "Epoch: " << flake.epoch << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ nix build -o $TEST_ROOT/result file://$flake2Dir:bar
|
|||
# Test whether indirect dependencies work.
|
||||
nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir:xyzzy
|
||||
|
||||
# Add dependency to flake3
|
||||
# Add dependency to flake3.
|
||||
rm $flake3Dir/flake.nix
|
||||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
|
@ -174,3 +174,7 @@ nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir:sth
|
|||
|
||||
# Check whether it saved the lockfile
|
||||
[[ ! (-z $(git -C $flake3Dir diff master)) ]]
|
||||
|
||||
# Unsupported epochs should be an error.
|
||||
sed -i $flake3Dir/flake.nix -e s/2019/2030/
|
||||
nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir:sth 2>&1 | grep 'unsupported epoch'
|
||||
|
|
Loading…
Reference in a new issue