mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Remove Input::locked
This commit is contained in:
parent
4f8b253ea7
commit
90e9f50a66
7 changed files with 37 additions and 17 deletions
|
@ -24,12 +24,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)
|
||||
|
@ -94,6 +90,11 @@ bool Input::isDirect() const
|
|||
return !scheme || scheme->isDirect(*this);
|
||||
}
|
||||
|
||||
bool Input::isLocked() const
|
||||
{
|
||||
return scheme && scheme->isLocked(*this);
|
||||
}
|
||||
|
||||
std::optional<CanonPath> Input::isRelative() const
|
||||
{
|
||||
assert(scheme);
|
||||
|
@ -172,8 +173,6 @@ void Input::checkLocks(Input & input) const
|
|||
|
||||
// FIXME
|
||||
#if 0
|
||||
input.locked = true;
|
||||
|
||||
assert(input.hasAllInfo());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ struct Input
|
|||
|
||||
std::shared_ptr<InputScheme> scheme; // note: can be null
|
||||
Attrs attrs;
|
||||
bool locked = false;
|
||||
|
||||
public:
|
||||
static Input fromURL(const std::string & url);
|
||||
|
@ -50,7 +49,7 @@ public:
|
|||
|
||||
/* Check whether this is a "locked" input, that is,
|
||||
one that contains a commit hash or content hash. */
|
||||
bool isLocked() const { return locked; }
|
||||
bool isLocked() const;
|
||||
|
||||
/* Only for relative path flakes, i.e. 'path:./foo', returns the
|
||||
relative path, i.e. './foo'. */
|
||||
|
@ -140,6 +139,9 @@ struct InputScheme
|
|||
virtual bool isDirect(const Input & input) const
|
||||
{ return true; }
|
||||
|
||||
virtual bool isLocked(const Input & input) const
|
||||
{ return false; }
|
||||
|
||||
virtual std::optional<CanonPath> isRelative(const Input & input) const
|
||||
{ return std::nullopt; }
|
||||
|
||||
|
|
|
@ -482,7 +482,6 @@ struct GitInputScheme : InputScheme
|
|||
//input.attrs.erase("narHash");
|
||||
auto narHash = store->queryPathInfo(storePath)->narHash;
|
||||
input.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true));
|
||||
input.locked = true;
|
||||
|
||||
return storePath;
|
||||
};
|
||||
|
@ -732,8 +731,6 @@ struct GitInputScheme : InputScheme
|
|||
input.attrs.insert_or_assign(
|
||||
"revCount",
|
||||
getRevCount(repoInfo, repoInfo.url, *input.getRev()));
|
||||
|
||||
input.locked = true;
|
||||
}
|
||||
|
||||
// FIXME: maybe we should use the timestamp of the last
|
||||
|
@ -744,6 +741,11 @@ struct GitInputScheme : InputScheme
|
|||
|
||||
return {makeFSInputAccessor(CanonPath(repoInfo.url), listFiles(repoInfo), std::move(makeNotAllowedError)), input};
|
||||
}
|
||||
|
||||
bool isLocked(const Input & input) const override
|
||||
{
|
||||
return (bool) input.getRev();
|
||||
}
|
||||
};
|
||||
|
||||
static auto rGitInputScheme = OnStartup([] { registerInputScheme(std::make_unique<GitInputScheme>()); });
|
||||
|
|
|
@ -194,8 +194,6 @@ struct GitArchiveInputScheme : InputScheme
|
|||
auto rev = input.getRev();
|
||||
if (!rev) rev = getRevFromRef(store, input);
|
||||
|
||||
input.locked = true;
|
||||
|
||||
input.attrs.erase("ref");
|
||||
input.attrs.insert_or_assign("rev", rev->gitRev());
|
||||
|
||||
|
@ -240,6 +238,11 @@ struct GitArchiveInputScheme : InputScheme
|
|||
|
||||
return {accessor, input2};
|
||||
}
|
||||
|
||||
bool isLocked(const Input & input) const override
|
||||
{
|
||||
return (bool) input.getRev();
|
||||
}
|
||||
};
|
||||
|
||||
struct GitHubInputScheme : GitArchiveInputScheme
|
||||
|
|
|
@ -229,7 +229,6 @@ struct MercurialInputScheme : InputScheme
|
|||
assert(input.getRev());
|
||||
assert(!origRev || origRev == input.getRev());
|
||||
input.attrs.insert_or_assign("revCount", getIntAttr(infoAttrs, "revCount"));
|
||||
input.locked = true;
|
||||
return storePath;
|
||||
};
|
||||
|
||||
|
@ -336,6 +335,11 @@ struct MercurialInputScheme : InputScheme
|
|||
|
||||
return {makeStorePathAccessor(store, storePath), input};
|
||||
}
|
||||
|
||||
bool isLocked(const Input & input) const override
|
||||
{
|
||||
return (bool) input.getRev();
|
||||
}
|
||||
};
|
||||
|
||||
static auto rMercurialInputScheme = OnStartup([] { registerInputScheme(std::make_unique<MercurialInputScheme>()); });
|
||||
|
|
|
@ -43,7 +43,10 @@ struct PathInputScheme : InputScheme
|
|||
/* Allow the user to pass in "fake" tree info
|
||||
attributes. This is useful for making a pinned tree
|
||||
work the same as the repository from which is exported
|
||||
(e.g. path:/nix/store/...-source?lastModified=1585388205&rev=b0c285...). */
|
||||
(e.g. path:/nix/store/...-source?lastModified=1585388205&rev=b0c285...).
|
||||
FIXME: remove this hack once we have a prepopulated
|
||||
flake input cache mechanism.
|
||||
*/
|
||||
if (name == "type" || name == "rev" || name == "revCount" || name == "lastModified" || name == "narHash" || name == "path")
|
||||
// checked in Input::fromAttrs
|
||||
;
|
||||
|
@ -76,6 +79,11 @@ struct PathInputScheme : InputScheme
|
|||
return CanonPath(path);
|
||||
}
|
||||
|
||||
bool isLocked(const Input & input) const override
|
||||
{
|
||||
return (bool) input.getNarHash();
|
||||
}
|
||||
|
||||
bool hasAllInfo(const Input & input) const override
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -237,6 +237,10 @@ struct CurlInputScheme : InputScheme
|
|||
return true;
|
||||
}
|
||||
|
||||
bool isLocked(const Input & input) const override
|
||||
{
|
||||
return (bool) input.getNarHash();
|
||||
}
|
||||
};
|
||||
|
||||
struct FileInputScheme : CurlInputScheme
|
||||
|
@ -261,7 +265,6 @@ struct FileInputScheme : CurlInputScheme
|
|||
// FIXME: remove?
|
||||
auto narHash = store->queryPathInfo(file.storePath)->narHash;
|
||||
input.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true));
|
||||
input.locked = true;
|
||||
|
||||
return {makeStorePathAccessor(store, file.storePath), input};
|
||||
}
|
||||
|
@ -290,7 +293,6 @@ struct TarballInputScheme : CurlInputScheme
|
|||
// FIXME: remove?
|
||||
auto narHash = store->queryPathInfo(storePath)->narHash;
|
||||
input.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true));
|
||||
input.locked = true;
|
||||
|
||||
return {makeStorePathAccessor(store, storePath), input};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue