mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 14:36:16 +02:00
Add helper function printInputPath()
This commit is contained in:
parent
29e0748847
commit
fc6c7af424
3 changed files with 21 additions and 12 deletions
|
@ -291,7 +291,7 @@ LockedFlake lockFlake(
|
|||
const InputPath & inputPathPrefix,
|
||||
std::shared_ptr<const Node> oldNode)
|
||||
{
|
||||
debug("computing lock file node '%s'", concatStringsSep("/", inputPathPrefix));
|
||||
debug("computing lock file node '%s'", printInputPath(inputPathPrefix));
|
||||
|
||||
/* Get the overrides (i.e. attributes of the form
|
||||
'inputs.nixops.inputs.nixpkgs.url = ...'). */
|
||||
|
@ -311,8 +311,8 @@ LockedFlake lockFlake(
|
|||
for (auto & [id, input2] : flakeInputs) {
|
||||
auto inputPath(inputPathPrefix);
|
||||
inputPath.push_back(id);
|
||||
auto inputPathS = concatStringsSep("/", inputPath);
|
||||
debug("computing input '%s'", concatStringsSep("/", inputPath));
|
||||
auto inputPathS = printInputPath(inputPath);
|
||||
debug("computing input '%s'", inputPathS);
|
||||
|
||||
/* Do we have an override for this input from one of the
|
||||
ancestors? */
|
||||
|
@ -332,6 +332,7 @@ LockedFlake lockFlake(
|
|||
/* Otherwise, it's relative to the current flake. */
|
||||
InputPath path(inputPathPrefix);
|
||||
for (auto & i : *input.follows) path.push_back(i);
|
||||
debug("input '%s' follows '%s'", inputPathS, printInputPath(path));
|
||||
follows.insert_or_assign(inputPath, path);
|
||||
}
|
||||
continue;
|
||||
|
@ -405,6 +406,7 @@ LockedFlake lockFlake(
|
|||
} else {
|
||||
/* We need to create a new lock file entry. So fetch
|
||||
this input. */
|
||||
debug("creating new input '%s'", inputPathS);
|
||||
|
||||
if (!lockFlags.allowMutable && !input.ref.input.isImmutable())
|
||||
throw Error("cannot update flake input '%s' in pure mode", inputPathS);
|
||||
|
@ -460,8 +462,8 @@ LockedFlake lockFlake(
|
|||
/* Insert edges for 'follows' overrides. */
|
||||
for (auto & [from, to] : follows) {
|
||||
debug("adding 'follows' node from '%s' to '%s'",
|
||||
concatStringsSep("/", from),
|
||||
concatStringsSep("/", to));
|
||||
printInputPath(from),
|
||||
printInputPath(to));
|
||||
|
||||
assert(!from.empty());
|
||||
|
||||
|
@ -474,8 +476,8 @@ LockedFlake lockFlake(
|
|||
auto toNode = newLockFile.root->findInput(to);
|
||||
if (!toNode)
|
||||
throw Error("flake input '%s' follows non-existent flake input '%s'",
|
||||
concatStringsSep("/", from),
|
||||
concatStringsSep("/", to));
|
||||
printInputPath(from),
|
||||
printInputPath(to));
|
||||
|
||||
fromParentNode->inputs.insert_or_assign(from.back(), toNode);
|
||||
}
|
||||
|
@ -483,11 +485,11 @@ LockedFlake lockFlake(
|
|||
for (auto & i : lockFlags.inputOverrides)
|
||||
if (!overridesUsed.count(i.first))
|
||||
warn("the flag '--override-input %s %s' does not match any input",
|
||||
concatStringsSep("/", i.first), i.second);
|
||||
printInputPath(i.first), i.second);
|
||||
|
||||
for (auto & i : lockFlags.inputUpdates)
|
||||
if (!updatesUsed.count(i))
|
||||
warn("the flag '--update-input %s' does not match any input", concatStringsSep("/", i));
|
||||
warn("the flag '--update-input %s' does not match any input", printInputPath(i));
|
||||
|
||||
debug("new lock file: %s", newLockFile);
|
||||
|
||||
|
|
|
@ -236,15 +236,15 @@ std::string diffLockFiles(const LockFile & oldLocks, const LockFile & newLocks)
|
|||
|
||||
while (i != oldFlat.end() || j != newFlat.end()) {
|
||||
if (j != newFlat.end() && (i == oldFlat.end() || i->first > j->first)) {
|
||||
res += fmt("* Added '%s': '%s'\n", concatStringsSep("/", j->first), j->second->lockedRef);
|
||||
res += fmt("* Added '%s': '%s'\n", printInputPath(j->first), j->second->lockedRef);
|
||||
++j;
|
||||
} 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", printInputPath(i->first));
|
||||
++i;
|
||||
} else {
|
||||
if (!(i->second->lockedRef == j->second->lockedRef)) {
|
||||
res += fmt("* Updated '%s': '%s' -> '%s'\n",
|
||||
concatStringsSep("/", i->first),
|
||||
printInputPath(i->first),
|
||||
i->second->lockedRef,
|
||||
j->second->lockedRef);
|
||||
}
|
||||
|
@ -256,4 +256,9 @@ std::string diffLockFiles(const LockFile & oldLocks, const LockFile & newLocks)
|
|||
return res;
|
||||
}
|
||||
|
||||
std::string printInputPath(const InputPath & path)
|
||||
{
|
||||
return concatStringsSep("/", path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ std::ostream & operator <<(std::ostream & stream, const LockFile & lockFile);
|
|||
|
||||
InputPath parseInputPath(std::string_view s);
|
||||
|
||||
std::string printInputPath(const InputPath & path);
|
||||
|
||||
std::string diffLockFiles(const LockFile & oldLocks, const LockFile & newLocks);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue