mirror of
https://github.com/NixOS/nix.git
synced 2025-12-13 12:31:04 +01:00
Input: Replace 'locked' bool by isLocked() method
It's better to just check whether the input has all the attributes needed to consider itself locked (e.g. whether a Git input has an 'rev' attribute). Also, the 'locked' field was actually incorrect for Git inputs: it would be set to true even for dirty worktrees. As a result, we got away with using fetchTree() internally even though fetchTree() requires a locked input in pure mode. In particular, this allowed '--override-input' to work by accident. The fix is to pass a set of "overrides" to call-flake.nix for all the unlocked inputs (i.e. the top-level flake and any --override-inputs).
This commit is contained in:
parent
78e7c98b02
commit
071dd2b3a4
16 changed files with 155 additions and 85 deletions
|
|
@ -45,12 +45,8 @@ static void fixupInput(Input & input)
|
|||
// Check common attributes.
|
||||
input.getType();
|
||||
input.getRef();
|
||||
if (input.getRev())
|
||||
input.locked = true;
|
||||
input.getRevCount();
|
||||
input.getLastModified();
|
||||
if (input.getNarHash())
|
||||
input.locked = true;
|
||||
}
|
||||
|
||||
Input Input::fromURL(const ParsedURL & url, bool requireTree)
|
||||
|
|
@ -140,6 +136,11 @@ bool Input::isDirect() const
|
|||
return !scheme || scheme->isDirect(*this);
|
||||
}
|
||||
|
||||
bool Input::isLocked() const
|
||||
{
|
||||
return scheme && scheme->isLocked(*this);
|
||||
}
|
||||
|
||||
Attrs Input::toAttrs() const
|
||||
{
|
||||
return attrs;
|
||||
|
|
@ -222,8 +223,6 @@ std::pair<StorePath, Input> Input::fetch(ref<Store> store) const
|
|||
input.to_string(), *prevRevCount);
|
||||
}
|
||||
|
||||
input.locked = true;
|
||||
|
||||
return {std::move(storePath), input};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue