mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-11 00:36:20 +02:00
Restore previous fetchGit behaviour
For compatibility, it returns a store path again, rather than a SourcePath.
This commit is contained in:
parent
3cc9dc38f3
commit
066ed1c830
1 changed files with 56 additions and 23 deletions
|
@ -11,28 +11,22 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
void emitTreeAttrs(
|
||||
static void emitTreeAttrs(
|
||||
EvalState & state,
|
||||
const SourcePath & path,
|
||||
const fetchers::Input & input,
|
||||
Value & v,
|
||||
std::function<void(Value &)> setOutPath,
|
||||
bool emptyRevFallback,
|
||||
bool forceDirty)
|
||||
{
|
||||
// FIXME?
|
||||
//assert(input.isLocked());
|
||||
|
||||
auto attrs = state.buildBindings(8);
|
||||
|
||||
attrs.alloc(state.sOutPath).mkPath(path);
|
||||
setOutPath(attrs.alloc(state.sOutPath));
|
||||
|
||||
// FIXME: support arbitrary input attributes.
|
||||
|
||||
#if 0
|
||||
auto narHash = input.getNarHash();
|
||||
assert(narHash);
|
||||
if (auto narHash = input.getNarHash())
|
||||
attrs.alloc("narHash").mkString(narHash->to_string(SRI, true));
|
||||
#endif
|
||||
|
||||
if (input.getType() == "git")
|
||||
attrs.alloc("submodules").mkBool(
|
||||
|
@ -66,6 +60,22 @@ void emitTreeAttrs(
|
|||
v.mkAttrs(attrs);
|
||||
}
|
||||
|
||||
void emitTreeAttrs(
|
||||
EvalState & state,
|
||||
const SourcePath & path,
|
||||
const fetchers::Input & input,
|
||||
Value & v,
|
||||
bool emptyRevFallback,
|
||||
bool forceDirty)
|
||||
{
|
||||
emitTreeAttrs(state, input, v,
|
||||
[&](Value & vOutPath) {
|
||||
vOutPath.mkPath(path);
|
||||
},
|
||||
emptyRevFallback,
|
||||
forceDirty);
|
||||
}
|
||||
|
||||
std::string fixURI(std::string uri, EvalState & state, const std::string & defaultScheme = "file")
|
||||
{
|
||||
state.checkURI(uri);
|
||||
|
@ -87,6 +97,7 @@ std::string fixURIForGit(std::string uri, EvalState & state)
|
|||
struct FetchTreeParams {
|
||||
bool emptyRevFallback = false;
|
||||
bool allowNameArgument = false;
|
||||
bool returnPath = true; // whether to return a lazily fetched SourcePath or a StorePath
|
||||
};
|
||||
|
||||
static void fetchTree(
|
||||
|
@ -186,13 +197,12 @@ static void fetchTree(
|
|||
if (evalSettings.pureEval && !input.isLocked())
|
||||
throw Error("in pure evaluation mode, 'fetchTree' requires a locked input, at %s", state.positions[pos]);
|
||||
|
||||
if (params.returnPath) {
|
||||
auto [accessor, input2] = input.lazyFetch(state.store);
|
||||
|
||||
if (!patches.empty())
|
||||
accessor = makePatchingInputAccessor(accessor, patches);
|
||||
|
||||
//state.allowPath(tree.storePath);
|
||||
|
||||
emitTreeAttrs(
|
||||
state,
|
||||
{ state.registerAccessor(accessor), CanonPath::root },
|
||||
|
@ -200,6 +210,23 @@ static void fetchTree(
|
|||
v,
|
||||
params.emptyRevFallback,
|
||||
false);
|
||||
} else {
|
||||
assert(patches.empty());
|
||||
|
||||
auto [tree, input2] = input.fetch(state.store);
|
||||
|
||||
auto storePath = state.store->printStorePath(tree.storePath);
|
||||
|
||||
emitTreeAttrs(
|
||||
state, input2, v,
|
||||
[&](Value & vOutPath) {
|
||||
vOutPath.mkString(storePath, {storePath});
|
||||
},
|
||||
params.emptyRevFallback,
|
||||
false);
|
||||
|
||||
//state.allowPath(tree.storePath);
|
||||
}
|
||||
}
|
||||
|
||||
static void prim_fetchTree(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||
|
@ -357,7 +384,13 @@ static RegisterPrimOp primop_fetchTarball({
|
|||
|
||||
static void prim_fetchGit(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||
{
|
||||
fetchTree(state, pos, args, v, "git", FetchTreeParams { .emptyRevFallback = true, .allowNameArgument = true });
|
||||
fetchTree(
|
||||
state, pos, args, v, "git",
|
||||
FetchTreeParams {
|
||||
.emptyRevFallback = true,
|
||||
.allowNameArgument = true,
|
||||
.returnPath = false,
|
||||
});
|
||||
}
|
||||
|
||||
static RegisterPrimOp primop_fetchGit({
|
||||
|
|
Loading…
Reference in a new issue