mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Remove Tree datatype
This commit is contained in:
parent
e7faf65784
commit
4f8f52ae58
7 changed files with 23 additions and 32 deletions
|
@ -93,7 +93,7 @@ SourcePath lookupFileArg(EvalState & state, std::string_view s)
|
|||
{
|
||||
if (isUri(s)) {
|
||||
auto storePath = fetchers::downloadTarball(
|
||||
state.store, resolveUri(s), "source", false).first.storePath;
|
||||
state.store, resolveUri(s), "source", false).first;
|
||||
auto accessor = makeFSInputAccessor(CanonPath(state.store->toRealPath(storePath)));
|
||||
state.registerAccessor(accessor);
|
||||
return {accessor, CanonPath::root};
|
||||
|
|
|
@ -790,7 +790,7 @@ SourcePath EvalState::findFile(SearchPath & searchPath, const std::string_view p
|
|||
if (isUri(elem.second)) {
|
||||
try {
|
||||
auto storePath = fetchers::downloadTarball(
|
||||
store, resolveUri(elem.second), "source", false).first.storePath;
|
||||
store, resolveUri(elem.second), "source", false).first;
|
||||
auto accessor = makeFSInputAccessor(CanonPath(store->toRealPath(storePath)));
|
||||
registerAccessor(accessor);
|
||||
res.emplace(SourcePath {accessor, CanonPath::root});
|
||||
|
|
|
@ -68,11 +68,11 @@ static void prim_fetchMercurial(EvalState & state, const PosIdx pos, Value * * a
|
|||
auto input = fetchers::Input::fromAttrs(std::move(attrs));
|
||||
|
||||
// FIXME: use name
|
||||
auto [tree, input2] = input.fetch(state.store);
|
||||
auto [storePath, input2] = input.fetch(state.store);
|
||||
|
||||
auto attrs2 = state.buildBindings(8);
|
||||
auto storePath = state.store->printStorePath(tree.storePath);
|
||||
attrs2.alloc(state.sOutPath).mkString(storePath, {storePath});
|
||||
auto storePath2 = state.store->printStorePath(storePath);
|
||||
attrs2.alloc(state.sOutPath).mkString(storePath2, {storePath2});
|
||||
if (input2.getRef())
|
||||
attrs2.alloc("branch").mkString(*input2.getRef());
|
||||
// Backward compatibility: set 'rev' to
|
||||
|
@ -84,7 +84,7 @@ static void prim_fetchMercurial(EvalState & state, const PosIdx pos, Value * * a
|
|||
attrs2.alloc("revCount").mkInt(*revCount);
|
||||
v.mkAttrs(attrs2);
|
||||
|
||||
state.allowPath(tree.storePath);
|
||||
state.allowPath(storePath);
|
||||
}
|
||||
|
||||
static RegisterPrimOp r_fetchMercurial("fetchMercurial", 1, prim_fetchMercurial);
|
||||
|
|
|
@ -196,19 +196,19 @@ static void fetchTree(
|
|||
params.emptyRevFallback,
|
||||
false);
|
||||
} else {
|
||||
auto [tree, input2] = input.fetch(state.store);
|
||||
auto [storePath, input2] = input.fetch(state.store);
|
||||
|
||||
auto storePath = state.store->printStorePath(tree.storePath);
|
||||
auto storePath2 = state.store->printStorePath(storePath);
|
||||
|
||||
emitTreeAttrs(
|
||||
state, input2, v,
|
||||
[&](Value & vOutPath) {
|
||||
vOutPath.mkString(storePath, {storePath});
|
||||
vOutPath.mkString(storePath2, {storePath2});
|
||||
},
|
||||
params.emptyRevFallback,
|
||||
false);
|
||||
|
||||
state.allowPath(tree.storePath);
|
||||
state.allowPath(storePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v
|
|||
// https://github.com/NixOS/nix/issues/4313
|
||||
auto storePath =
|
||||
unpack
|
||||
? fetchers::downloadTarball(state.store, *url, name, (bool) expectedHash).first.storePath
|
||||
? fetchers::downloadTarball(state.store, *url, name, (bool) expectedHash).first
|
||||
: fetchers::downloadFile(state.store, *url, name, (bool) expectedHash).storePath;
|
||||
|
||||
if (expectedHash) {
|
||||
|
|
|
@ -112,7 +112,7 @@ bool Input::contains(const Input & other) const
|
|||
return false;
|
||||
}
|
||||
|
||||
std::pair<Tree, Input> Input::fetch(ref<Store> store) const
|
||||
std::pair<StorePath, Input> Input::fetch(ref<Store> store) const
|
||||
{
|
||||
if (!scheme)
|
||||
throw Error("cannot fetch unsupported input '%s'", attrsToJSON(toAttrs()));
|
||||
|
@ -129,7 +129,7 @@ std::pair<Tree, Input> Input::fetch(ref<Store> store) const
|
|||
debug("using substituted/cached input '%s' in '%s'",
|
||||
to_string(), store->printStorePath(storePath));
|
||||
|
||||
return {Tree { .actualPath = store->toRealPath(storePath), .storePath = std::move(storePath) }, *this};
|
||||
return {std::move(storePath), *this};
|
||||
} catch (Error & e) {
|
||||
debug("substitution of input '%s' failed: %s", to_string(), e.what());
|
||||
}
|
||||
|
@ -144,14 +144,9 @@ std::pair<Tree, Input> Input::fetch(ref<Store> store) const
|
|||
}
|
||||
}();
|
||||
|
||||
Tree tree {
|
||||
.actualPath = store->toRealPath(storePath),
|
||||
.storePath = storePath,
|
||||
};
|
||||
|
||||
checkLocked(*store, storePath, input);
|
||||
|
||||
return {std::move(tree), input};
|
||||
return {std::move(storePath), input};
|
||||
}
|
||||
|
||||
void Input::checkLocked(Store & store, const StorePath & storePath, Input & input) const
|
||||
|
|
|
@ -13,12 +13,6 @@ namespace nix { class Store; }
|
|||
|
||||
namespace nix::fetchers {
|
||||
|
||||
struct Tree
|
||||
{
|
||||
Path actualPath;
|
||||
StorePath storePath;
|
||||
};
|
||||
|
||||
struct InputScheme;
|
||||
|
||||
/* The Input object is generated by a specific fetcher, based on the
|
||||
|
@ -70,7 +64,7 @@ public:
|
|||
|
||||
/* Fetch the input into the Nix store, returning the location in
|
||||
the Nix store and the locked input. */
|
||||
std::pair<Tree, Input> fetch(ref<Store> store) const;
|
||||
std::pair<StorePath, Input> fetch(ref<Store> store) const;
|
||||
|
||||
/* Return an InputAccessor that allows access to files in the
|
||||
input without copying it to the store. Also return a possibly
|
||||
|
@ -178,7 +172,7 @@ DownloadFileResult downloadFile(
|
|||
bool locked,
|
||||
const Headers & headers = {});
|
||||
|
||||
std::pair<Tree, time_t> downloadTarball(
|
||||
std::pair<StorePath, time_t> downloadTarball(
|
||||
ref<Store> store,
|
||||
const std::string & url,
|
||||
const std::string & name,
|
||||
|
|
|
@ -110,7 +110,7 @@ DownloadFileResult downloadFile(
|
|||
};
|
||||
}
|
||||
|
||||
std::pair<Tree, time_t> downloadTarball(
|
||||
std::pair<StorePath, time_t> downloadTarball(
|
||||
ref<Store> store,
|
||||
const std::string & url,
|
||||
const std::string & name,
|
||||
|
@ -127,7 +127,7 @@ std::pair<Tree, time_t> downloadTarball(
|
|||
|
||||
if (cached && !cached->expired)
|
||||
return {
|
||||
Tree { .actualPath = store->toRealPath(cached->storePath), .storePath = std::move(cached->storePath) },
|
||||
std::move(cached->storePath),
|
||||
getIntAttr(cached->infoAttrs, "lastModified")
|
||||
};
|
||||
|
||||
|
@ -164,7 +164,7 @@ std::pair<Tree, time_t> downloadTarball(
|
|||
locked);
|
||||
|
||||
return {
|
||||
Tree { .actualPath = store->toRealPath(*unpackedStorePath), .storePath = std::move(*unpackedStorePath) },
|
||||
std::move(*unpackedStorePath),
|
||||
lastModified,
|
||||
};
|
||||
}
|
||||
|
@ -273,8 +273,10 @@ struct TarballInputScheme : CurlInputScheme
|
|||
|
||||
std::pair<StorePath, Input> fetch(ref<Store> store, const Input & input) override
|
||||
{
|
||||
auto tree = downloadTarball(store, getStrAttr(input.attrs, "url"), input.getName(), false).first;
|
||||
return {std::move(tree.storePath), input};
|
||||
return {
|
||||
downloadTarball(store, getStrAttr(input.attrs, "url"), input.getName(), false).first,
|
||||
input
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue