mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 06:56:14 +02:00
Give a better error message in case of unlocked inputs
This commit is contained in:
parent
1395210a68
commit
1c7d0b716d
3 changed files with 8 additions and 6 deletions
|
@ -630,9 +630,9 @@ LockedFlake lockFlake(
|
|||
|
||||
if (lockFlags.writeLockFile) {
|
||||
if (auto sourcePath = topRef.input.getSourcePath()) {
|
||||
if (!newLockFile.isLocked()) {
|
||||
if (auto unlockedInput = newLockFile.isUnlocked()) {
|
||||
if (fetchSettings.warnDirty)
|
||||
warn("will not write lock file of flake '%s' because it has an unlocked input", topRef);
|
||||
warn("will not write lock file of flake '%s' because it has an unlocked input ('%s')", topRef, *unlockedInput);
|
||||
} else {
|
||||
if (!lockFlags.updateLockFile)
|
||||
throw Error("flake '%s' requires lock file changes but they're not allowed due to '--no-update-lock-file'", topRef);
|
||||
|
|
|
@ -197,7 +197,7 @@ void LockFile::write(const Path & path) const
|
|||
writeFile(path, fmt("%s\n", *this));
|
||||
}
|
||||
|
||||
bool LockFile::isLocked() const
|
||||
std::optional<FlakeRef> LockFile::isUnlocked() const
|
||||
{
|
||||
std::unordered_set<std::shared_ptr<const Node>> nodes;
|
||||
|
||||
|
@ -219,10 +219,10 @@ bool LockFile::isLocked() const
|
|||
if (node
|
||||
&& !node->lockedRef.input.isLocked()
|
||||
&& !node->lockedRef.input.isRelative())
|
||||
return false;
|
||||
return node->lockedRef;
|
||||
}
|
||||
|
||||
return true;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool LockFile::operator ==(const LockFile & other) const
|
||||
|
|
|
@ -60,7 +60,9 @@ struct LockFile
|
|||
|
||||
void write(const Path & path) const;
|
||||
|
||||
bool isLocked() const;
|
||||
/* Check whether this lock file has any unlocked inputs. If so,
|
||||
return one. */
|
||||
std::optional<FlakeRef> isUnlocked() const;
|
||||
|
||||
bool operator ==(const LockFile & other) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue