mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
Remove isConsideredLocked()
This commit is contained in:
parent
4113fdf2f0
commit
9e240ecced
4 changed files with 14 additions and 19 deletions
|
@ -183,7 +183,7 @@ static void fetchTree(
|
||||||
if (!state.settings.pureEval && !input.isDirect() && experimentalFeatureSettings.isEnabled(Xp::Flakes))
|
if (!state.settings.pureEval && !input.isDirect() && experimentalFeatureSettings.isEnabled(Xp::Flakes))
|
||||||
input = lookupInRegistries(state.store, input).first;
|
input = lookupInRegistries(state.store, input).first;
|
||||||
|
|
||||||
if (state.settings.pureEval && !input.isConsideredLocked(state.fetchSettings)) {
|
if (state.settings.pureEval && !input.isLocked()) {
|
||||||
if (input.getNarHash())
|
if (input.getNarHash())
|
||||||
warn(
|
warn(
|
||||||
"Input '%s' is unlocked (e.g. lacks a Git revision) but does have a NAR hash. "
|
"Input '%s' is unlocked (e.g. lacks a Git revision) but does have a NAR hash. "
|
||||||
|
|
|
@ -155,12 +155,6 @@ bool Input::isLocked() const
|
||||||
return scheme && scheme->isLocked(*this);
|
return scheme && scheme->isLocked(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Input::isConsideredLocked(
|
|
||||||
const Settings & settings) const
|
|
||||||
{
|
|
||||||
return isLocked() || (settings.allowDirtyLocks && getNarHash());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Input::isFinal() const
|
bool Input::isFinal() const
|
||||||
{
|
{
|
||||||
return maybeGetBoolAttr(attrs, "__final").value_or(false);
|
return maybeGetBoolAttr(attrs, "__final").value_or(false);
|
||||||
|
|
|
@ -90,15 +90,6 @@ public:
|
||||||
*/
|
*/
|
||||||
bool isLocked() const;
|
bool isLocked() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Return whether the input is either locked, or, if
|
|
||||||
* `allow-dirty-locks` is enabled, it has a NAR hash. In the
|
|
||||||
* latter case, we can verify the input but we may not be able to
|
|
||||||
* fetch it from anywhere.
|
|
||||||
*/
|
|
||||||
bool isConsideredLocked(
|
|
||||||
const Settings & settings) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only for relative path flakes, i.e. 'path:./foo', returns the
|
* Only for relative path flakes, i.e. 'path:./foo', returns the
|
||||||
* relative path, i.e. './foo'.
|
* relative path, i.e. './foo'.
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
|
#include "fetch-settings.hh"
|
||||||
|
#include "flake/settings.hh"
|
||||||
#include "lockfile.hh"
|
#include "lockfile.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
|
#include "strings.hh"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
@ -9,8 +12,6 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include "strings.hh"
|
|
||||||
#include "flake/settings.hh"
|
|
||||||
|
|
||||||
namespace nix::flake {
|
namespace nix::flake {
|
||||||
|
|
||||||
|
@ -255,11 +256,20 @@ std::optional<FlakeRef> LockFile::isUnlocked(const fetchers::Settings & fetchSet
|
||||||
|
|
||||||
visit(root);
|
visit(root);
|
||||||
|
|
||||||
|
/* Return whether the input is either locked, or, if
|
||||||
|
`allow-dirty-locks` is enabled, it has a NAR hash. In the
|
||||||
|
latter case, we can verify the input but we may not be able to
|
||||||
|
fetch it from anywhere. */
|
||||||
|
auto isConsideredLocked = [&](const fetchers::Input & input)
|
||||||
|
{
|
||||||
|
return input.isLocked() || (fetchSettings.allowDirtyLocks && input.getNarHash());
|
||||||
|
};
|
||||||
|
|
||||||
for (auto & i : nodes) {
|
for (auto & i : nodes) {
|
||||||
if (i == ref<const Node>(root)) continue;
|
if (i == ref<const Node>(root)) continue;
|
||||||
auto node = i.dynamic_pointer_cast<const LockedNode>();
|
auto node = i.dynamic_pointer_cast<const LockedNode>();
|
||||||
if (node
|
if (node
|
||||||
&& (!node->lockedRef.input.isConsideredLocked(fetchSettings)
|
&& (!isConsideredLocked(node->lockedRef.input)
|
||||||
|| !node->lockedRef.input.isFinal())
|
|| !node->lockedRef.input.isFinal())
|
||||||
&& !node->lockedRef.input.isRelative())
|
&& !node->lockedRef.input.isRelative())
|
||||||
return node->lockedRef;
|
return node->lockedRef;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue