Renamed ref / resolvedRef -> lockedRef
This commit is contained in:
parent
887730aab3
commit
b270869466
|
@ -152,31 +152,31 @@ static Flake getFlake(EvalState & state, const FlakeRef & originalRef,
|
||||||
|
|
||||||
auto [sourceInfo, resolvedInput] = flakeRef.input->fetchTree(state.store);
|
auto [sourceInfo, resolvedInput] = flakeRef.input->fetchTree(state.store);
|
||||||
|
|
||||||
FlakeRef resolvedRef(resolvedInput, flakeRef.subdir);
|
FlakeRef lockedRef(resolvedInput, flakeRef.subdir);
|
||||||
|
|
||||||
debug("got flake source '%s' from '%s'",
|
debug("got flake source '%s' from '%s'",
|
||||||
state.store->printStorePath(sourceInfo.storePath), resolvedRef);
|
state.store->printStorePath(sourceInfo.storePath), lockedRef);
|
||||||
|
|
||||||
flakeCache.push_back({originalRef, resolvedRef});
|
flakeCache.push_back({originalRef, lockedRef});
|
||||||
flakeCache.push_back({flakeRef, resolvedRef});
|
flakeCache.push_back({flakeRef, lockedRef});
|
||||||
|
|
||||||
if (state.allowedPaths)
|
if (state.allowedPaths)
|
||||||
state.allowedPaths->insert(sourceInfo.actualPath);
|
state.allowedPaths->insert(sourceInfo.actualPath);
|
||||||
|
|
||||||
// Guard against symlink attacks.
|
// Guard against symlink attacks.
|
||||||
auto flakeFile = canonPath(sourceInfo.actualPath + "/" + resolvedRef.subdir + "/flake.nix");
|
auto flakeFile = canonPath(sourceInfo.actualPath + "/" + lockedRef.subdir + "/flake.nix");
|
||||||
if (!isInDir(flakeFile, sourceInfo.actualPath))
|
if (!isInDir(flakeFile, sourceInfo.actualPath))
|
||||||
throw Error("'flake.nix' file of flake '%s' escapes from '%s'",
|
throw Error("'flake.nix' file of flake '%s' escapes from '%s'",
|
||||||
resolvedRef, state.store->printStorePath(sourceInfo.storePath));
|
lockedRef, state.store->printStorePath(sourceInfo.storePath));
|
||||||
|
|
||||||
Flake flake {
|
Flake flake {
|
||||||
.originalRef = originalRef,
|
.originalRef = originalRef,
|
||||||
.resolvedRef = resolvedRef,
|
.lockedRef = lockedRef,
|
||||||
.sourceInfo = std::make_shared<fetchers::Tree>(std::move(sourceInfo))
|
.sourceInfo = std::make_shared<fetchers::Tree>(std::move(sourceInfo))
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!pathExists(flakeFile))
|
if (!pathExists(flakeFile))
|
||||||
throw Error("source tree referenced by '%s' does not contain a '%s/flake.nix' file", resolvedRef, resolvedRef.subdir);
|
throw Error("source tree referenced by '%s' does not contain a '%s/flake.nix' file", lockedRef, lockedRef.subdir);
|
||||||
|
|
||||||
Value vInfo;
|
Value vInfo;
|
||||||
state.evalFile(flakeFile, vInfo, true); // FIXME: symlink attack
|
state.evalFile(flakeFile, vInfo, true); // FIXME: symlink attack
|
||||||
|
@ -259,18 +259,18 @@ static std::pair<fetchers::Tree, FlakeRef> getNonFlake(
|
||||||
|
|
||||||
auto [sourceInfo, resolvedInput] = flakeRef.input->fetchTree(state.store);
|
auto [sourceInfo, resolvedInput] = flakeRef.input->fetchTree(state.store);
|
||||||
|
|
||||||
FlakeRef resolvedRef(resolvedInput, flakeRef.subdir);
|
FlakeRef lockedRef(resolvedInput, flakeRef.subdir);
|
||||||
|
|
||||||
debug("got non-flake source '%s' from '%s'",
|
debug("got non-flake source '%s' from '%s'",
|
||||||
state.store->printStorePath(sourceInfo.storePath), resolvedRef);
|
state.store->printStorePath(sourceInfo.storePath), lockedRef);
|
||||||
|
|
||||||
flakeCache.push_back({originalRef, resolvedRef});
|
flakeCache.push_back({originalRef, lockedRef});
|
||||||
flakeCache.push_back({flakeRef, resolvedRef});
|
flakeCache.push_back({flakeRef, lockedRef});
|
||||||
|
|
||||||
if (state.allowedPaths)
|
if (state.allowedPaths)
|
||||||
state.allowedPaths->insert(sourceInfo.actualPath);
|
state.allowedPaths->insert(sourceInfo.actualPath);
|
||||||
|
|
||||||
return std::make_pair(std::move(sourceInfo), resolvedRef);
|
return std::make_pair(std::move(sourceInfo), lockedRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flattenLockFile(
|
static void flattenLockFile(
|
||||||
|
@ -298,18 +298,18 @@ static std::string diffLockFiles(const LockedInputs & oldLocks, const LockedInpu
|
||||||
|
|
||||||
while (i != oldFlat.end() || j != newFlat.end()) {
|
while (i != oldFlat.end() || j != newFlat.end()) {
|
||||||
if (j != newFlat.end() && (i == oldFlat.end() || i->first > j->first)) {
|
if (j != newFlat.end() && (i == oldFlat.end() || i->first > j->first)) {
|
||||||
res += fmt(" added '%s': '%s'\n", concatStringsSep("/", j->first), j->second->ref);
|
res += fmt(" added '%s': '%s'\n", concatStringsSep("/", j->first), j->second->lockedRef);
|
||||||
++j;
|
++j;
|
||||||
} else if (i != oldFlat.end() && (j == newFlat.end() || i->first < j->first)) {
|
} else if (i != oldFlat.end() && (j == newFlat.end() || i->first < j->first)) {
|
||||||
res += fmt(" removed '%s'\n", concatStringsSep("/", i->first));
|
res += fmt(" removed '%s'\n", concatStringsSep("/", i->first));
|
||||||
++i;
|
++i;
|
||||||
} else {
|
} else {
|
||||||
if (!(i->second->ref == j->second->ref)) {
|
if (!(i->second->lockedRef == j->second->lockedRef)) {
|
||||||
assert(i->second->ref.to_string() != j->second->ref.to_string());
|
assert(i->second->lockedRef.to_string() != j->second->lockedRef.to_string());
|
||||||
res += fmt(" updated '%s': '%s' -> '%s'\n",
|
res += fmt(" updated '%s': '%s' -> '%s'\n",
|
||||||
concatStringsSep("/", i->first),
|
concatStringsSep("/", i->first),
|
||||||
i->second->ref,
|
i->second->lockedRef,
|
||||||
j->second->ref);
|
j->second->lockedRef);
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
++j;
|
++j;
|
||||||
|
@ -337,7 +337,7 @@ LockedFlake lockFlake(
|
||||||
if (!lockFlags.recreateLockFile) {
|
if (!lockFlags.recreateLockFile) {
|
||||||
// FIXME: symlink attack
|
// FIXME: symlink attack
|
||||||
oldLockFile = LockFile::read(
|
oldLockFile = LockFile::read(
|
||||||
flake.sourceInfo->actualPath + "/" + flake.resolvedRef.subdir + "/flake.lock");
|
flake.sourceInfo->actualPath + "/" + flake.lockedRef.subdir + "/flake.lock");
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("old lock file: %s", oldLockFile);
|
debug("old lock file: %s", oldLockFile);
|
||||||
|
@ -443,7 +443,7 @@ LockedFlake lockFlake(
|
||||||
&& std::equal(inputPath.begin(), inputPath.end(), lb->begin());
|
&& std::equal(inputPath.begin(), inputPath.end(), lb->begin());
|
||||||
|
|
||||||
if (hasChildUpdate) {
|
if (hasChildUpdate) {
|
||||||
auto inputFlake = getFlake(state, oldLock->second.ref, false, flakeCache);
|
auto inputFlake = getFlake(state, oldLock->second.lockedRef, false, flakeCache);
|
||||||
|
|
||||||
updateLocks(inputFlake.inputs,
|
updateLocks(inputFlake.inputs,
|
||||||
(const LockedInputs &) oldLock->second,
|
(const LockedInputs &) oldLock->second,
|
||||||
|
@ -478,7 +478,7 @@ LockedFlake lockFlake(
|
||||||
lockFlags.useRegistries, flakeCache);
|
lockFlags.useRegistries, flakeCache);
|
||||||
|
|
||||||
newLocks.inputs.insert_or_assign(id,
|
newLocks.inputs.insert_or_assign(id,
|
||||||
LockedInput(inputFlake.resolvedRef, inputFlake.originalRef, inputFlake.sourceInfo->info));
|
LockedInput(inputFlake.lockedRef, inputFlake.originalRef, inputFlake.sourceInfo->info));
|
||||||
|
|
||||||
/* Recursively process the inputs of this
|
/* Recursively process the inputs of this
|
||||||
flake. Also, unless we already have this
|
flake. Also, unless we already have this
|
||||||
|
@ -488,16 +488,16 @@ LockedFlake lockFlake(
|
||||||
oldLock != oldLocks.inputs.end()
|
oldLock != oldLocks.inputs.end()
|
||||||
? (const LockedInputs &) oldLock->second
|
? (const LockedInputs &) oldLock->second
|
||||||
: LockFile::read(
|
: LockFile::read(
|
||||||
inputFlake.sourceInfo->actualPath + "/" + inputFlake.resolvedRef.subdir + "/flake.lock"),
|
inputFlake.sourceInfo->actualPath + "/" + inputFlake.lockedRef.subdir + "/flake.lock"),
|
||||||
newLocks.inputs.find(id)->second,
|
newLocks.inputs.find(id)->second,
|
||||||
inputPath);
|
inputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
auto [sourceInfo, resolvedRef] = getNonFlake(state, input.ref,
|
auto [sourceInfo, lockedRef] = getNonFlake(state, input.ref,
|
||||||
lockFlags.useRegistries, flakeCache);
|
lockFlags.useRegistries, flakeCache);
|
||||||
newLocks.inputs.insert_or_assign(id,
|
newLocks.inputs.insert_or_assign(id,
|
||||||
LockedInput(resolvedRef, input.ref, sourceInfo.info));
|
LockedInput(lockedRef, input.ref, sourceInfo.info));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,11 +606,11 @@ static void prim_callFlake(EvalState & state, const Pos & pos, Value * * args, V
|
||||||
auto lazyInput = (LazyInput *) args[0]->attrs;
|
auto lazyInput = (LazyInput *) args[0]->attrs;
|
||||||
|
|
||||||
if (lazyInput->isFlake) {
|
if (lazyInput->isFlake) {
|
||||||
auto flake = getFlake(state, lazyInput->lockedInput.ref, false);
|
auto flake = getFlake(state, lazyInput->lockedInput.lockedRef, false);
|
||||||
|
|
||||||
if (flake.sourceInfo->info.narHash != lazyInput->lockedInput.info.narHash)
|
if (flake.sourceInfo->info.narHash != lazyInput->lockedInput.info.narHash)
|
||||||
throw Error("the content hash of flake '%s' (%s) doesn't match the hash recorded in the referring lock file (%s)",
|
throw Error("the content hash of flake '%s' (%s) doesn't match the hash recorded in the referring lock file (%s)",
|
||||||
lazyInput->lockedInput.ref,
|
lazyInput->lockedInput.lockedRef,
|
||||||
flake.sourceInfo->info.narHash.to_string(SRI),
|
flake.sourceInfo->info.narHash.to_string(SRI),
|
||||||
lazyInput->lockedInput.info.narHash.to_string(SRI));
|
lazyInput->lockedInput.info.narHash.to_string(SRI));
|
||||||
|
|
||||||
|
@ -622,11 +622,11 @@ static void prim_callFlake(EvalState & state, const Pos & pos, Value * * args, V
|
||||||
callFlake(state, flake, lazyInput->lockedInput, v);
|
callFlake(state, flake, lazyInput->lockedInput, v);
|
||||||
} else {
|
} else {
|
||||||
FlakeCache flakeCache;
|
FlakeCache flakeCache;
|
||||||
auto [sourceInfo, resolvedRef] = getNonFlake(state, lazyInput->lockedInput.ref, false, flakeCache);
|
auto [sourceInfo, lockedRef] = getNonFlake(state, lazyInput->lockedInput.lockedRef, false, flakeCache);
|
||||||
|
|
||||||
if (sourceInfo.info.narHash != lazyInput->lockedInput.info.narHash)
|
if (sourceInfo.info.narHash != lazyInput->lockedInput.info.narHash)
|
||||||
throw Error("the content hash of repository '%s' (%s) doesn't match the hash recorded in the referring lock file (%s)",
|
throw Error("the content hash of repository '%s' (%s) doesn't match the hash recorded in the referring lock file (%s)",
|
||||||
lazyInput->lockedInput.ref,
|
lazyInput->lockedInput.lockedRef,
|
||||||
sourceInfo.info.narHash.to_string(SRI),
|
sourceInfo.info.narHash.to_string(SRI),
|
||||||
lazyInput->lockedInput.info.narHash.to_string(SRI));
|
lazyInput->lockedInput.info.narHash.to_string(SRI));
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ static void prim_callFlake(EvalState & state, const Pos & pos, Value * * args, V
|
||||||
|
|
||||||
mkString(*state.allocAttr(v, state.sOutPath), pathS, {pathS});
|
mkString(*state.allocAttr(v, state.sOutPath), pathS, {pathS});
|
||||||
|
|
||||||
emitSourceInfoAttrs(state, resolvedRef, sourceInfo, v);
|
emitSourceInfoAttrs(state, lockedRef, sourceInfo, v);
|
||||||
|
|
||||||
v.attrs->sort();
|
v.attrs->sort();
|
||||||
}
|
}
|
||||||
|
@ -676,7 +676,7 @@ void callFlake(EvalState & state,
|
||||||
|
|
||||||
auto & vSourceInfo = *state.allocValue();
|
auto & vSourceInfo = *state.allocValue();
|
||||||
state.mkAttrs(vSourceInfo, 8);
|
state.mkAttrs(vSourceInfo, 8);
|
||||||
emitSourceInfoAttrs(state, flake.resolvedRef, *flake.sourceInfo, vSourceInfo);
|
emitSourceInfoAttrs(state, flake.lockedRef, *flake.sourceInfo, vSourceInfo);
|
||||||
vSourceInfo.attrs->sort();
|
vSourceInfo.attrs->sort();
|
||||||
|
|
||||||
vInputs.attrs->push_back(Attr(state.sSelf, &vRes));
|
vInputs.attrs->push_back(Attr(state.sSelf, &vRes));
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct FlakeInput
|
||||||
struct Flake
|
struct Flake
|
||||||
{
|
{
|
||||||
FlakeRef originalRef;
|
FlakeRef originalRef;
|
||||||
FlakeRef resolvedRef;
|
FlakeRef lockedRef;
|
||||||
std::optional<std::string> description;
|
std::optional<std::string> description;
|
||||||
std::shared_ptr<const fetchers::Tree> sourceInfo;
|
std::shared_ptr<const fetchers::Tree> sourceInfo;
|
||||||
FlakeInputs inputs;
|
FlakeInputs inputs;
|
||||||
|
|
|
@ -80,12 +80,12 @@ static TreeInfo parseTreeInfo(const nlohmann::json & json)
|
||||||
|
|
||||||
LockedInput::LockedInput(const nlohmann::json & json)
|
LockedInput::LockedInput(const nlohmann::json & json)
|
||||||
: LockedInputs(json)
|
: LockedInputs(json)
|
||||||
, ref(getFlakeRef(json, "url", "uri", "resolvedRef"))
|
, lockedRef(getFlakeRef(json, "url", "uri", "locked"))
|
||||||
, originalRef(getFlakeRef(json, "originalUrl", "originalUri", "originalRef"))
|
, originalRef(getFlakeRef(json, "originalUrl", "originalUri", "original"))
|
||||||
, info(parseTreeInfo(json))
|
, info(parseTreeInfo(json))
|
||||||
{
|
{
|
||||||
if (!ref.isImmutable())
|
if (!lockedRef.isImmutable())
|
||||||
throw Error("lockfile contains mutable flakeref '%s'", ref);
|
throw Error("lockfile contains mutable flakeref '%s'", lockedRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
static nlohmann::json treeInfoToJson(const TreeInfo & info)
|
static nlohmann::json treeInfoToJson(const TreeInfo & info)
|
||||||
|
@ -103,8 +103,8 @@ static nlohmann::json treeInfoToJson(const TreeInfo & info)
|
||||||
nlohmann::json LockedInput::toJson() const
|
nlohmann::json LockedInput::toJson() const
|
||||||
{
|
{
|
||||||
auto json = LockedInputs::toJson();
|
auto json = LockedInputs::toJson();
|
||||||
json["originalRef"] = fetchers::attrsToJson(originalRef.toAttrs());
|
json["original"] = fetchers::attrsToJson(originalRef.toAttrs());
|
||||||
json["resolvedRef"] = fetchers::attrsToJson(ref.toAttrs());
|
json["locked"] = fetchers::attrsToJson(lockedRef.toAttrs());
|
||||||
json["info"] = treeInfoToJson(info);
|
json["info"] = treeInfoToJson(info);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ nlohmann::json LockedInputs::toJson() const
|
||||||
bool LockedInputs::isImmutable() const
|
bool LockedInputs::isImmutable() const
|
||||||
{
|
{
|
||||||
for (auto & i : inputs)
|
for (auto & i : inputs)
|
||||||
if (!i.second.ref.isImmutable() || !i.second.isImmutable()) return false;
|
if (!i.second.lockedRef.isImmutable() || !i.second.isImmutable()) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,11 @@ struct LockedInputs
|
||||||
/* Lock file information about a flake input. */
|
/* Lock file information about a flake input. */
|
||||||
struct LockedInput : LockedInputs
|
struct LockedInput : LockedInputs
|
||||||
{
|
{
|
||||||
FlakeRef ref, originalRef;
|
FlakeRef lockedRef, originalRef;
|
||||||
TreeInfo info;
|
TreeInfo info;
|
||||||
|
|
||||||
LockedInput(const FlakeRef & ref, const FlakeRef & originalRef, const TreeInfo & info)
|
LockedInput(const FlakeRef & lockedRef, const FlakeRef & originalRef, const TreeInfo & info)
|
||||||
: ref(ref), originalRef(originalRef), info(info)
|
: lockedRef(lockedRef), originalRef(originalRef), info(info)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
LockedInput(const nlohmann::json & json);
|
LockedInput(const nlohmann::json & json);
|
||||||
|
@ -47,7 +47,7 @@ struct LockedInput : LockedInputs
|
||||||
bool operator ==(const LockedInput & other) const
|
bool operator ==(const LockedInput & other) const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
ref == other.ref
|
lockedRef == other.lockedRef
|
||||||
&& originalRef == other.originalRef
|
&& originalRef == other.originalRef
|
||||||
&& info == other.info
|
&& info == other.info
|
||||||
&& inputs == other.inputs;
|
&& inputs == other.inputs;
|
||||||
|
|
|
@ -79,12 +79,12 @@ struct CmdFlakeList : EvalCommand
|
||||||
|
|
||||||
static void printFlakeInfo(const Store & store, const Flake & flake)
|
static void printFlakeInfo(const Store & store, const Flake & flake)
|
||||||
{
|
{
|
||||||
std::cout << fmt("URL: %s\n", flake.resolvedRef.input->to_string());
|
std::cout << fmt("URL: %s\n", flake.lockedRef.input->to_string());
|
||||||
std::cout << fmt("Edition: %s\n", flake.edition);
|
std::cout << fmt("Edition: %s\n", flake.edition);
|
||||||
if (flake.description)
|
if (flake.description)
|
||||||
std::cout << fmt("Description: %s\n", *flake.description);
|
std::cout << fmt("Description: %s\n", *flake.description);
|
||||||
std::cout << fmt("Path: %s\n", store.printStorePath(flake.sourceInfo->storePath));
|
std::cout << fmt("Path: %s\n", store.printStorePath(flake.sourceInfo->storePath));
|
||||||
if (auto rev = flake.resolvedRef.input->getRev())
|
if (auto rev = flake.lockedRef.input->getRev())
|
||||||
std::cout << fmt("Revision: %s\n", rev->to_string(Base16, false));
|
std::cout << fmt("Revision: %s\n", rev->to_string(Base16, false));
|
||||||
if (flake.sourceInfo->info.revCount)
|
if (flake.sourceInfo->info.revCount)
|
||||||
std::cout << fmt("Revisions: %s\n", *flake.sourceInfo->info.revCount);
|
std::cout << fmt("Revisions: %s\n", *flake.sourceInfo->info.revCount);
|
||||||
|
@ -99,8 +99,8 @@ static nlohmann::json flakeToJson(const Store & store, const Flake & flake)
|
||||||
if (flake.description)
|
if (flake.description)
|
||||||
j["description"] = *flake.description;
|
j["description"] = *flake.description;
|
||||||
j["edition"] = flake.edition;
|
j["edition"] = flake.edition;
|
||||||
j["url"] = flake.resolvedRef.input->to_string();
|
j["url"] = flake.lockedRef.input->to_string();
|
||||||
if (auto rev = flake.resolvedRef.input->getRev())
|
if (auto rev = flake.lockedRef.input->getRev())
|
||||||
j["revision"] = rev->to_string(Base16, false);
|
j["revision"] = rev->to_string(Base16, false);
|
||||||
if (flake.sourceInfo->info.revCount)
|
if (flake.sourceInfo->info.revCount)
|
||||||
j["revCount"] = *flake.sourceInfo->info.revCount;
|
j["revCount"] = *flake.sourceInfo->info.revCount;
|
||||||
|
@ -201,7 +201,7 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
|
||||||
if (json)
|
if (json)
|
||||||
std::cout << ((LockedInputs &) flake.lockFile).toJson() << "\n";
|
std::cout << ((LockedInputs &) flake.lockFile).toJson() << "\n";
|
||||||
else {
|
else {
|
||||||
std::cout << fmt("%s\n", flake.flake.resolvedRef);
|
std::cout << fmt("%s\n", flake.flake.lockedRef);
|
||||||
|
|
||||||
std::function<void(const LockedInputs & inputs, const std::string & prefix)> recurse;
|
std::function<void(const LockedInputs & inputs, const std::string & prefix)> recurse;
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
|
||||||
//auto tree2 = tree.child(i + 1 == inputs.inputs.size());
|
//auto tree2 = tree.child(i + 1 == inputs.inputs.size());
|
||||||
bool last = i + 1 == inputs.inputs.size();
|
bool last = i + 1 == inputs.inputs.size();
|
||||||
std::cout << fmt("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s\n",
|
std::cout << fmt("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s\n",
|
||||||
prefix + (last ? treeLast : treeConn), input.first, input.second.ref);
|
prefix + (last ? treeLast : treeConn), input.first, input.second.lockedRef);
|
||||||
recurse(input.second, prefix + (last ? treeNull : treeLine));
|
recurse(input.second, prefix + (last ? treeNull : treeLine));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -667,7 +667,7 @@ struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun
|
||||||
for (auto & input : inputs.inputs) {
|
for (auto & input : inputs.inputs) {
|
||||||
auto jsonObj3 = jsonObj2 ? jsonObj2->object(input.first) : std::optional<JSONObject>();
|
auto jsonObj3 = jsonObj2 ? jsonObj2->object(input.first) : std::optional<JSONObject>();
|
||||||
if (!dryRun)
|
if (!dryRun)
|
||||||
input.second.ref.input->fetchTree(store);
|
input.second.lockedRef.input->fetchTree(store);
|
||||||
auto storePath = input.second.computeStorePath(*store);
|
auto storePath = input.second.computeStorePath(*store);
|
||||||
if (jsonObj3)
|
if (jsonObj3)
|
||||||
jsonObj3->attr("path", store->printStorePath(storePath));
|
jsonObj3->attr("path", store->printStorePath(storePath));
|
||||||
|
|
|
@ -348,7 +348,7 @@ std::tuple<std::string, FlakeRef, flake::EvalCache::Derivation> InstallableFlake
|
||||||
auto drv = evalCache.getDerivation(fingerprint, attrPath);
|
auto drv = evalCache.getDerivation(fingerprint, attrPath);
|
||||||
if (drv) {
|
if (drv) {
|
||||||
if (state->store->isValidPath(drv->drvPath))
|
if (state->store->isValidPath(drv->drvPath))
|
||||||
return {attrPath, lockedFlake.flake.resolvedRef, std::move(*drv)};
|
return {attrPath, lockedFlake.flake.lockedRef, std::move(*drv)};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vOutputs)
|
if (!vOutputs)
|
||||||
|
@ -370,7 +370,7 @@ std::tuple<std::string, FlakeRef, flake::EvalCache::Derivation> InstallableFlake
|
||||||
|
|
||||||
evalCache.addDerivation(fingerprint, attrPath, drv);
|
evalCache.addDerivation(fingerprint, attrPath, drv);
|
||||||
|
|
||||||
return {attrPath, lockedFlake.flake.resolvedRef, std::move(drv)};
|
return {attrPath, lockedFlake.flake.lockedRef, std::move(drv)};
|
||||||
} catch (AttrPathNotFound & e) {
|
} catch (AttrPathNotFound & e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,7 +480,7 @@ cat > $flake3Dir/flake.nix <<EOF
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
nix flake update $flake3Dir
|
nix flake update $flake3Dir
|
||||||
[[ $(jq .inputs.foo.resolvedRef $flake3Dir/flake.lock) = $(jq .inputs.bar.resolvedRef $flake3Dir/flake.lock) ]]
|
[[ $(jq .inputs.foo.locked $flake3Dir/flake.lock) = $(jq .inputs.bar.locked $flake3Dir/flake.lock) ]]
|
||||||
|
|
||||||
cat > $flake3Dir/flake.nix <<EOF
|
cat > $flake3Dir/flake.nix <<EOF
|
||||||
{
|
{
|
||||||
|
@ -494,7 +494,7 @@ cat > $flake3Dir/flake.nix <<EOF
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
nix flake update $flake3Dir
|
nix flake update $flake3Dir
|
||||||
[[ $(jq .inputs.bar.resolvedRef.url $flake3Dir/flake.lock) =~ flake1 ]]
|
[[ $(jq .inputs.bar.locked.url $flake3Dir/flake.lock) =~ flake1 ]]
|
||||||
|
|
||||||
cat > $flake3Dir/flake.nix <<EOF
|
cat > $flake3Dir/flake.nix <<EOF
|
||||||
{
|
{
|
||||||
|
@ -508,7 +508,7 @@ cat > $flake3Dir/flake.nix <<EOF
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
nix flake update $flake3Dir
|
nix flake update $flake3Dir
|
||||||
[[ $(jq .inputs.bar.resolvedRef.url $flake3Dir/flake.lock) =~ flake2 ]]
|
[[ $(jq .inputs.bar.locked.url $flake3Dir/flake.lock) =~ flake2 ]]
|
||||||
|
|
||||||
# Test overriding inputs of inputs.
|
# Test overriding inputs of inputs.
|
||||||
cat > $flake3Dir/flake.nix <<EOF
|
cat > $flake3Dir/flake.nix <<EOF
|
||||||
|
@ -523,7 +523,7 @@ cat > $flake3Dir/flake.nix <<EOF
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
nix flake update $flake3Dir
|
nix flake update $flake3Dir
|
||||||
[[ $(jq .inputs.flake2.inputs.flake1.resolvedRef.url $flake3Dir/flake.lock) =~ flake7 ]]
|
[[ $(jq .inputs.flake2.inputs.flake1.locked.url $flake3Dir/flake.lock) =~ flake7 ]]
|
||||||
|
|
||||||
cat > $flake3Dir/flake.nix <<EOF
|
cat > $flake3Dir/flake.nix <<EOF
|
||||||
{
|
{
|
||||||
|
@ -538,7 +538,7 @@ cat > $flake3Dir/flake.nix <<EOF
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
nix flake update $flake3Dir --recreate-lock-file
|
nix flake update $flake3Dir --recreate-lock-file
|
||||||
[[ $(jq .inputs.flake2.inputs.flake1.resolvedRef.url $flake3Dir/flake.lock) =~ flake7 ]]
|
[[ $(jq .inputs.flake2.inputs.flake1.locked.url $flake3Dir/flake.lock) =~ flake7 ]]
|
||||||
|
|
||||||
# Test Mercurial flakes.
|
# Test Mercurial flakes.
|
||||||
if [[ -z $(type -p hg) ]]; then
|
if [[ -z $(type -p hg) ]]; then
|
||||||
|
@ -605,20 +605,20 @@ nix build -o $TEST_ROOT/result "file://$TEST_ROOT/flake.tar.gz?narHash=sha256-qQ
|
||||||
# Test --override-input.
|
# Test --override-input.
|
||||||
git -C $flake3Dir reset --hard
|
git -C $flake3Dir reset --hard
|
||||||
nix flake update $flake3Dir --override-input flake2/flake1 flake5
|
nix flake update $flake3Dir --override-input flake2/flake1 flake5
|
||||||
[[ $(jq .inputs.flake2.inputs.flake1.resolvedRef.url $flake3Dir/flake.lock) =~ flake5 ]]
|
[[ $(jq .inputs.flake2.inputs.flake1.locked.url $flake3Dir/flake.lock) =~ flake5 ]]
|
||||||
|
|
||||||
nix flake update $flake3Dir --override-input flake2/flake1 flake1
|
nix flake update $flake3Dir --override-input flake2/flake1 flake1
|
||||||
[[ $(jq -r .inputs.flake2.inputs.flake1.resolvedRef.rev $flake3Dir/flake.lock) =~ $hash2 ]]
|
[[ $(jq -r .inputs.flake2.inputs.flake1.locked.rev $flake3Dir/flake.lock) =~ $hash2 ]]
|
||||||
|
|
||||||
nix flake update $flake3Dir --override-input flake2/flake1 flake1/master/$hash1
|
nix flake update $flake3Dir --override-input flake2/flake1 flake1/master/$hash1
|
||||||
[[ $(jq -r .inputs.flake2.inputs.flake1.resolvedRef.rev $flake3Dir/flake.lock) =~ $hash1 ]]
|
[[ $(jq -r .inputs.flake2.inputs.flake1.locked.rev $flake3Dir/flake.lock) =~ $hash1 ]]
|
||||||
|
|
||||||
# Test --update-input.
|
# Test --update-input.
|
||||||
nix flake update $flake3Dir
|
nix flake update $flake3Dir
|
||||||
[[ $(jq -r .inputs.flake2.inputs.flake1.resolvedRef.rev $flake3Dir/flake.lock) = $hash1 ]]
|
[[ $(jq -r .inputs.flake2.inputs.flake1.locked.rev $flake3Dir/flake.lock) = $hash1 ]]
|
||||||
|
|
||||||
nix flake update $flake3Dir --update-input flake2/flake1
|
nix flake update $flake3Dir --update-input flake2/flake1
|
||||||
[[ $(jq -r .inputs.flake2.inputs.flake1.resolvedRef.rev $flake3Dir/flake.lock) =~ $hash2 ]]
|
[[ $(jq -r .inputs.flake2.inputs.flake1.locked.rev $flake3Dir/flake.lock) =~ $hash2 ]]
|
||||||
|
|
||||||
# Test 'nix flake list-inputs'.
|
# Test 'nix flake list-inputs'.
|
||||||
[[ $(nix flake list-inputs $flake3Dir | wc -l) == 5 ]]
|
[[ $(nix flake list-inputs $flake3Dir | wc -l) == 5 ]]
|
||||||
|
|
Loading…
Reference in a new issue