mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 23:06:16 +02:00
Use corepkgsFS for derivation.nix
This commit is contained in:
parent
a18b3c665a
commit
78232889c0
5 changed files with 25 additions and 23 deletions
|
@ -475,6 +475,10 @@ EvalState::EvalState(
|
||||||
throw RestrictedPathError("access to absolute path '%1%' is forbidden %2%", path, modeInformation);
|
throw RestrictedPathError("access to absolute path '%1%' is forbidden %2%", path, modeInformation);
|
||||||
}))
|
}))
|
||||||
, corepkgsFS(makeMemoryInputAccessor())
|
, corepkgsFS(makeMemoryInputAccessor())
|
||||||
|
, derivationInternal{corepkgsFS->addFile(
|
||||||
|
CanonPath("derivation-internal.nix"),
|
||||||
|
#include "primops/derivation.nix.gen.hh"
|
||||||
|
)}
|
||||||
, store(store)
|
, store(store)
|
||||||
, buildStore(buildStore ? buildStore : store)
|
, buildStore(buildStore ? buildStore : store)
|
||||||
, debugRepl(0)
|
, debugRepl(0)
|
||||||
|
@ -508,12 +512,12 @@ EvalState::EvalState(
|
||||||
for (auto & i : searchPath)
|
for (auto & i : searchPath)
|
||||||
resolveSearchPathElem(i, true);
|
resolveSearchPathElem(i, true);
|
||||||
|
|
||||||
createBaseEnv();
|
|
||||||
|
|
||||||
corepkgsFS->addFile(
|
corepkgsFS->addFile(
|
||||||
CanonPath("fetchurl.nix"),
|
CanonPath("fetchurl.nix"),
|
||||||
#include "fetchurl.nix.gen.hh"
|
#include "fetchurl.nix.gen.hh"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
createBaseEnv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1449,11 +1453,13 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
|
||||||
state.forceValue(*vAttrs, (pos2 ? pos2 : this->pos ) );
|
state.forceValue(*vAttrs, (pos2 ? pos2 : this->pos ) );
|
||||||
|
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
auto pos2r = state.positions[pos2];
|
if (pos2) {
|
||||||
// FIXME: use MemoryAccessor
|
auto pos2r = state.positions[pos2];
|
||||||
if (pos2 /* && pos2r.origin != Pos(state.derivationNixPath) */)
|
auto origin = std::get_if<SourcePath>(&pos2r.origin);
|
||||||
state.addErrorTrace(e, pos2, "while evaluating the attribute '%1%'",
|
if (!origin || *origin != state.derivationInternal)
|
||||||
showAttrPath(state, env, attrPath));
|
state.addErrorTrace(e, pos2, "while evaluating the attribute '%1%'",
|
||||||
|
showAttrPath(state, env, attrPath));
|
||||||
|
}
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,6 @@ public:
|
||||||
SymbolTable symbols;
|
SymbolTable symbols;
|
||||||
PosTable positions;
|
PosTable positions;
|
||||||
|
|
||||||
static inline std::string derivationNixPath = "//builtin/derivation.nix";
|
|
||||||
|
|
||||||
const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName, sValue,
|
const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName, sValue,
|
||||||
sSystem, sOverrides, sOutputs, sOutputName, sIgnoreNulls,
|
sSystem, sOverrides, sOutputs, sOutputName, sIgnoreNulls,
|
||||||
sFile, sLine, sColumn, sFunctor, sToString,
|
sFile, sLine, sColumn, sFunctor, sToString,
|
||||||
|
@ -103,7 +101,6 @@ public:
|
||||||
sDescription, sSelf, sEpsilon, sStartSet, sOperator, sKey, sPath,
|
sDescription, sSelf, sEpsilon, sStartSet, sOperator, sKey, sPath,
|
||||||
sPrefix,
|
sPrefix,
|
||||||
sOutputSpecified;
|
sOutputSpecified;
|
||||||
Symbol sDerivationNix;
|
|
||||||
|
|
||||||
/* If set, force copying files to the Nix store even if they
|
/* If set, force copying files to the Nix store even if they
|
||||||
already exist there. */
|
already exist there. */
|
||||||
|
@ -111,8 +108,10 @@ public:
|
||||||
|
|
||||||
Bindings emptyBindings;
|
Bindings emptyBindings;
|
||||||
|
|
||||||
ref<FSInputAccessor> rootFS;
|
const ref<FSInputAccessor> rootFS;
|
||||||
ref<MemoryInputAccessor> corepkgsFS;
|
const ref<MemoryInputAccessor> corepkgsFS;
|
||||||
|
|
||||||
|
const SourcePath derivationInternal;
|
||||||
|
|
||||||
std::unordered_map<InputAccessor *, ref<InputAccessor>> inputAccessors;
|
std::unordered_map<InputAccessor *, ref<InputAccessor>> inputAccessors;
|
||||||
|
|
||||||
|
|
|
@ -3979,8 +3979,6 @@ void EvalState::createBaseEnv()
|
||||||
|
|
||||||
/* Add a wrapper around the derivation primop that computes the
|
/* Add a wrapper around the derivation primop that computes the
|
||||||
`drvPath' and `outPath' attributes lazily. */
|
`drvPath' and `outPath' attributes lazily. */
|
||||||
// FIXME: use corepkgsFS.
|
|
||||||
sDerivationNix = symbols.create(derivationNixPath);
|
|
||||||
auto vDerivation = allocValue();
|
auto vDerivation = allocValue();
|
||||||
addConstant("derivation", vDerivation);
|
addConstant("derivation", vDerivation);
|
||||||
|
|
||||||
|
@ -3992,12 +3990,7 @@ void EvalState::createBaseEnv()
|
||||||
|
|
||||||
/* Note: we have to initialize the 'derivation' constant *after*
|
/* Note: we have to initialize the 'derivation' constant *after*
|
||||||
building baseEnv/staticBaseEnv because it uses 'builtins'. */
|
building baseEnv/staticBaseEnv because it uses 'builtins'. */
|
||||||
char code[] =
|
evalFile(derivationInternal, *vDerivation);
|
||||||
#include "primops/derivation.nix.gen.hh"
|
|
||||||
// the parser needs two NUL bytes as terminators; one of them
|
|
||||||
// is implied by being a C string.
|
|
||||||
"\0";
|
|
||||||
eval(parse(code, sizeof(code), Pos::string_tag(), rootPath("/"), staticBaseEnv), *vDerivation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -258,9 +258,11 @@ struct MemoryInputAccessorImpl : MemoryInputAccessor
|
||||||
throw UnimplementedError("MemoryInputAccessor::readLink");
|
throw UnimplementedError("MemoryInputAccessor::readLink");
|
||||||
}
|
}
|
||||||
|
|
||||||
void addFile(CanonPath path, std::string && contents) override
|
SourcePath addFile(CanonPath path, std::string && contents) override
|
||||||
{
|
{
|
||||||
files.emplace(std::move(path), std::move(contents));
|
files.emplace(path, std::move(contents));
|
||||||
|
|
||||||
|
return {ref(shared_from_this()), std::move(path)};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -77,9 +77,11 @@ ref<FSInputAccessor> makeFSInputAccessor(
|
||||||
std::optional<std::set<CanonPath>> && allowedPaths = {},
|
std::optional<std::set<CanonPath>> && allowedPaths = {},
|
||||||
MakeNotAllowedError && makeNotAllowedError = {});
|
MakeNotAllowedError && makeNotAllowedError = {});
|
||||||
|
|
||||||
|
struct SourcePath;
|
||||||
|
|
||||||
struct MemoryInputAccessor : InputAccessor
|
struct MemoryInputAccessor : InputAccessor
|
||||||
{
|
{
|
||||||
virtual void addFile(CanonPath path, std::string && contents) = 0;
|
virtual SourcePath addFile(CanonPath path, std::string && contents) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
ref<MemoryInputAccessor> makeMemoryInputAccessor();
|
ref<MemoryInputAccessor> makeMemoryInputAccessor();
|
||||||
|
|
Loading…
Reference in a new issue