forked from lix-project/lix
Cleanup
This commit is contained in:
parent
b270869466
commit
958ec5de56
|
@ -22,7 +22,7 @@ static FlakeRef maybeLookupFlake(
|
|||
const FlakeRef & flakeRef,
|
||||
bool allowLookup)
|
||||
{
|
||||
if (!flakeRef.isDirect()) {
|
||||
if (!flakeRef.input->isDirect()) {
|
||||
if (allowLookup)
|
||||
return flakeRef.resolve(state.store);
|
||||
else
|
||||
|
@ -150,9 +150,7 @@ static Flake getFlake(EvalState & state, const FlakeRef & originalRef,
|
|||
maybeLookupFlake(state,
|
||||
lookupInFlakeCache(flakeCache, originalRef), allowLookup));
|
||||
|
||||
auto [sourceInfo, resolvedInput] = flakeRef.input->fetchTree(state.store);
|
||||
|
||||
FlakeRef lockedRef(resolvedInput, flakeRef.subdir);
|
||||
auto [sourceInfo, lockedRef] = flakeRef.fetchTree(state.store);
|
||||
|
||||
debug("got flake source '%s' from '%s'",
|
||||
state.store->printStorePath(sourceInfo.storePath), lockedRef);
|
||||
|
@ -257,9 +255,7 @@ static std::pair<fetchers::Tree, FlakeRef> getNonFlake(
|
|||
maybeLookupFlake(state,
|
||||
lookupInFlakeCache(flakeCache, originalRef), allowLookup));
|
||||
|
||||
auto [sourceInfo, resolvedInput] = flakeRef.input->fetchTree(state.store);
|
||||
|
||||
FlakeRef lockedRef(resolvedInput, flakeRef.subdir);
|
||||
auto [sourceInfo, lockedRef] = flakeRef.fetchTree(state.store);
|
||||
|
||||
debug("got non-flake source '%s' from '%s'",
|
||||
state.store->printStorePath(sourceInfo.storePath), lockedRef);
|
||||
|
@ -470,7 +466,7 @@ LockedFlake lockFlake(
|
|||
/* We need to update/create a new lock file
|
||||
entry. So fetch the flake/non-flake. */
|
||||
|
||||
if (!lockFlags.allowMutable && !input.ref.isImmutable())
|
||||
if (!lockFlags.allowMutable && !input.ref.input->isImmutable())
|
||||
throw Error("cannot update flake input '%s' in pure mode", inputPathS);
|
||||
|
||||
if (input.isFlake) {
|
||||
|
|
|
@ -27,16 +27,6 @@ fetchers::Input::Attrs FlakeRef::toAttrs() const
|
|||
return attrs;
|
||||
}
|
||||
|
||||
bool FlakeRef::isDirect() const
|
||||
{
|
||||
return input->isDirect();
|
||||
}
|
||||
|
||||
bool FlakeRef::isImmutable() const
|
||||
{
|
||||
return input->isImmutable();
|
||||
}
|
||||
|
||||
std::ostream & operator << (std::ostream & str, const FlakeRef & flakeRef)
|
||||
{
|
||||
str << flakeRef.to_string();
|
||||
|
@ -182,4 +172,10 @@ FlakeRef FlakeRef::fromAttrs(const fetchers::Input::Attrs & attrs)
|
|||
fetchers::maybeGetStrAttr(attrs, "subdir").value_or(""));
|
||||
}
|
||||
|
||||
std::pair<fetchers::Tree, FlakeRef> FlakeRef::fetchTree(ref<Store> store) const
|
||||
{
|
||||
auto [tree, lockedInput] = input->fetchTree(store);
|
||||
return {std::move(tree), FlakeRef(lockedInput, subdir)};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,17 +31,11 @@ struct FlakeRef
|
|||
|
||||
fetchers::Input::Attrs toAttrs() const;
|
||||
|
||||
/* Check whether this is a "direct" flake reference, that is, not
|
||||
a flake ID, which requires a lookup in the flake registry. */
|
||||
bool isDirect() const;
|
||||
|
||||
/* Check whether this is an "immutable" flake reference, that is,
|
||||
one that contains a commit hash or content hash. */
|
||||
bool isImmutable() const;
|
||||
|
||||
FlakeRef resolve(ref<Store> store) const;
|
||||
|
||||
static FlakeRef fromAttrs(const fetchers::Input::Attrs & attrs);
|
||||
|
||||
std::pair<fetchers::Tree, FlakeRef> fetchTree(ref<Store> store) const;
|
||||
};
|
||||
|
||||
std::ostream & operator << (std::ostream & str, const FlakeRef & flakeRef);
|
||||
|
|
|
@ -84,7 +84,7 @@ LockedInput::LockedInput(const nlohmann::json & json)
|
|||
, originalRef(getFlakeRef(json, "originalUrl", "originalUri", "original"))
|
||||
, info(parseTreeInfo(json))
|
||||
{
|
||||
if (!lockedRef.isImmutable())
|
||||
if (!lockedRef.input->isImmutable())
|
||||
throw Error("lockfile contains mutable flakeref '%s'", lockedRef);
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ nlohmann::json LockedInputs::toJson() const
|
|||
bool LockedInputs::isImmutable() const
|
||||
{
|
||||
for (auto & i : inputs)
|
||||
if (!i.second.lockedRef.isImmutable() || !i.second.isImmutable()) return false;
|
||||
if (!i.second.lockedRef.input->isImmutable() || !i.second.isImmutable()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,12 @@ struct Input : std::enable_shared_from_this<Input>
|
|||
|
||||
virtual bool operator ==(const Input & other) const { return false; }
|
||||
|
||||
/* Check whether this is a "direct" input, that is, not
|
||||
one that goes through a registry. */
|
||||
virtual bool isDirect() const { return true; }
|
||||
|
||||
/* Check whether this is an "immutable" input, that is,
|
||||
one that contains a commit hash or content hash. */
|
||||
virtual bool isImmutable() const { return (bool) narHash; }
|
||||
|
||||
virtual bool contains(const Input & other) const { return false; }
|
||||
|
|
|
@ -330,7 +330,7 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf
|
|||
for (size_t i = 0; i < manifest.elements.size(); ++i) {
|
||||
auto & element(manifest.elements[i]);
|
||||
if (element.source
|
||||
&& !element.source->originalRef.isImmutable()
|
||||
&& !element.source->originalRef.input->isImmutable()
|
||||
&& matches(*store, element, i, matchers))
|
||||
{
|
||||
Activity act(*logger, lvlChatty, actUnknown,
|
||||
|
|
Loading…
Reference in a new issue