mirror of
https://github.com/NixOS/nix.git
synced 2025-12-12 20:11:03 +01:00
Merge remote-tracking branch 'origin/master' into relative-flakes
This commit is contained in:
commit
21fc07c1a4
1142 changed files with 31230 additions and 23784 deletions
|
|
@ -35,9 +35,11 @@ nlohmann::json dumpRegisterInputSchemeInfo() {
|
|||
return res;
|
||||
}
|
||||
|
||||
Input Input::fromURL(const std::string & url, bool requireTree)
|
||||
Input Input::fromURL(
|
||||
const Settings & settings,
|
||||
const std::string & url, bool requireTree)
|
||||
{
|
||||
return fromURL(parseURL(url), requireTree);
|
||||
return fromURL(settings, parseURL(url), requireTree);
|
||||
}
|
||||
|
||||
static void fixupInput(Input & input)
|
||||
|
|
@ -49,10 +51,12 @@ static void fixupInput(Input & input)
|
|||
input.getLastModified();
|
||||
}
|
||||
|
||||
Input Input::fromURL(const ParsedURL & url, bool requireTree)
|
||||
Input Input::fromURL(
|
||||
const Settings & settings,
|
||||
const ParsedURL & url, bool requireTree)
|
||||
{
|
||||
for (auto & [_, inputScheme] : *inputSchemes) {
|
||||
auto res = inputScheme->inputFromURL(url, requireTree);
|
||||
auto res = inputScheme->inputFromURL(settings, url, requireTree);
|
||||
if (res) {
|
||||
experimentalFeatureSettings.require(inputScheme->experimentalFeature());
|
||||
res->scheme = inputScheme;
|
||||
|
|
@ -64,7 +68,7 @@ Input Input::fromURL(const ParsedURL & url, bool requireTree)
|
|||
throw Error("input '%s' is unsupported", url.url);
|
||||
}
|
||||
|
||||
Input Input::fromAttrs(Attrs && attrs)
|
||||
Input Input::fromAttrs(const Settings & settings, Attrs && attrs)
|
||||
{
|
||||
auto schemeName = ({
|
||||
auto schemeNameOpt = maybeGetStrAttr(attrs, "type");
|
||||
|
|
@ -78,7 +82,7 @@ Input Input::fromAttrs(Attrs && attrs)
|
|||
// but not all of them. Doing this is to support those other
|
||||
// operations which are supposed to be robust on
|
||||
// unknown/uninterpretable inputs.
|
||||
Input input;
|
||||
Input input { settings };
|
||||
input.attrs = attrs;
|
||||
fixupInput(input);
|
||||
return input;
|
||||
|
|
@ -99,7 +103,7 @@ Input Input::fromAttrs(Attrs && attrs)
|
|||
if (name != "type" && allowedAttrs.count(name) == 0)
|
||||
throw Error("input attribute '%s' not supported by scheme '%s'", name, schemeName);
|
||||
|
||||
auto res = inputScheme->inputFromAttrs(attrs);
|
||||
auto res = inputScheme->inputFromAttrs(settings, attrs);
|
||||
if (!res) return raw();
|
||||
res->scheme = inputScheme;
|
||||
fixupInput(*res);
|
||||
|
|
@ -152,7 +156,7 @@ Attrs Input::toAttrs() const
|
|||
return attrs;
|
||||
}
|
||||
|
||||
bool Input::operator ==(const Input & other) const
|
||||
bool Input::operator ==(const Input & other) const noexcept
|
||||
{
|
||||
return attrs == other.attrs;
|
||||
}
|
||||
|
|
@ -172,24 +176,6 @@ std::pair<StorePath, Input> Input::fetchToStore(ref<Store> store) const
|
|||
if (!scheme)
|
||||
throw Error("cannot fetch unsupported input '%s'", attrsToJSON(toAttrs()));
|
||||
|
||||
/* The tree may already be in the Nix store, or it could be
|
||||
substituted (which is often faster than fetching from the
|
||||
original source). So check that. */
|
||||
if (getNarHash()) {
|
||||
try {
|
||||
auto storePath = computeStorePath(*store);
|
||||
|
||||
store->ensurePath(storePath);
|
||||
|
||||
debug("using substituted/cached input '%s' in '%s'",
|
||||
to_string(), store->printStorePath(storePath));
|
||||
|
||||
return {std::move(storePath), *this};
|
||||
} catch (Error & e) {
|
||||
debug("substitution of input '%s' failed: %s", to_string(), e.what());
|
||||
}
|
||||
}
|
||||
|
||||
auto [storePath, input] = [&]() -> std::pair<StorePath, Input> {
|
||||
try {
|
||||
auto [accessor, final] = getAccessorUnchecked(store);
|
||||
|
|
@ -266,6 +252,7 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(ref<Store> sto
|
|||
|
||||
auto [accessor, final] = scheme->getAccessor(store, *this);
|
||||
|
||||
assert(!accessor->fingerprint);
|
||||
accessor->fingerprint = scheme->getFingerprint(store, final);
|
||||
|
||||
return {accessor, std::move(final)};
|
||||
|
|
@ -311,7 +298,7 @@ StorePath Input::computeStorePath(Store & store) const
|
|||
if (!narHash)
|
||||
throw Error("cannot compute store path for unlocked input '%s'", to_string());
|
||||
return store.makeFixedOutputPath(getName(), FixedOutputInfo {
|
||||
.method = FileIngestionMethod::Recursive,
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.hash = *narHash,
|
||||
.references = {},
|
||||
});
|
||||
|
|
@ -424,7 +411,7 @@ namespace nlohmann {
|
|||
using namespace nix;
|
||||
|
||||
fetchers::PublicKey adl_serializer<fetchers::PublicKey>::from_json(const json & json) {
|
||||
fetchers::PublicKey res = { };
|
||||
fetchers::PublicKey res = { };
|
||||
if (auto type = optionalValueAt(json, "type"))
|
||||
res.type = getString(*type);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue