mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 14:56:15 +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);
|
||||
}))
|
||||
, corepkgsFS(makeMemoryInputAccessor())
|
||||
, derivationInternal{corepkgsFS->addFile(
|
||||
CanonPath("derivation-internal.nix"),
|
||||
#include "primops/derivation.nix.gen.hh"
|
||||
)}
|
||||
, store(store)
|
||||
, buildStore(buildStore ? buildStore : store)
|
||||
, debugRepl(0)
|
||||
|
@ -508,12 +512,12 @@ EvalState::EvalState(
|
|||
for (auto & i : searchPath)
|
||||
resolveSearchPathElem(i, true);
|
||||
|
||||
createBaseEnv();
|
||||
|
||||
corepkgsFS->addFile(
|
||||
CanonPath("fetchurl.nix"),
|
||||
#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 ) );
|
||||
|
||||
} catch (Error & e) {
|
||||
auto pos2r = state.positions[pos2];
|
||||
// FIXME: use MemoryAccessor
|
||||
if (pos2 /* && pos2r.origin != Pos(state.derivationNixPath) */)
|
||||
state.addErrorTrace(e, pos2, "while evaluating the attribute '%1%'",
|
||||
showAttrPath(state, env, attrPath));
|
||||
if (pos2) {
|
||||
auto pos2r = state.positions[pos2];
|
||||
auto origin = std::get_if<SourcePath>(&pos2r.origin);
|
||||
if (!origin || *origin != state.derivationInternal)
|
||||
state.addErrorTrace(e, pos2, "while evaluating the attribute '%1%'",
|
||||
showAttrPath(state, env, attrPath));
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,8 +91,6 @@ public:
|
|||
SymbolTable symbols;
|
||||
PosTable positions;
|
||||
|
||||
static inline std::string derivationNixPath = "//builtin/derivation.nix";
|
||||
|
||||
const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName, sValue,
|
||||
sSystem, sOverrides, sOutputs, sOutputName, sIgnoreNulls,
|
||||
sFile, sLine, sColumn, sFunctor, sToString,
|
||||
|
@ -103,7 +101,6 @@ public:
|
|||
sDescription, sSelf, sEpsilon, sStartSet, sOperator, sKey, sPath,
|
||||
sPrefix,
|
||||
sOutputSpecified;
|
||||
Symbol sDerivationNix;
|
||||
|
||||
/* If set, force copying files to the Nix store even if they
|
||||
already exist there. */
|
||||
|
@ -111,8 +108,10 @@ public:
|
|||
|
||||
Bindings emptyBindings;
|
||||
|
||||
ref<FSInputAccessor> rootFS;
|
||||
ref<MemoryInputAccessor> corepkgsFS;
|
||||
const ref<FSInputAccessor> rootFS;
|
||||
const ref<MemoryInputAccessor> corepkgsFS;
|
||||
|
||||
const SourcePath derivationInternal;
|
||||
|
||||
std::unordered_map<InputAccessor *, ref<InputAccessor>> inputAccessors;
|
||||
|
||||
|
|
|
@ -3979,8 +3979,6 @@ void EvalState::createBaseEnv()
|
|||
|
||||
/* Add a wrapper around the derivation primop that computes the
|
||||
`drvPath' and `outPath' attributes lazily. */
|
||||
// FIXME: use corepkgsFS.
|
||||
sDerivationNix = symbols.create(derivationNixPath);
|
||||
auto vDerivation = allocValue();
|
||||
addConstant("derivation", vDerivation);
|
||||
|
||||
|
@ -3992,12 +3990,7 @@ void EvalState::createBaseEnv()
|
|||
|
||||
/* Note: we have to initialize the 'derivation' constant *after*
|
||||
building baseEnv/staticBaseEnv because it uses 'builtins'. */
|
||||
char code[] =
|
||||
#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);
|
||||
evalFile(derivationInternal, *vDerivation);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -258,9 +258,11 @@ struct MemoryInputAccessorImpl : MemoryInputAccessor
|
|||
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 = {},
|
||||
MakeNotAllowedError && makeNotAllowedError = {});
|
||||
|
||||
struct SourcePath;
|
||||
|
||||
struct MemoryInputAccessor : InputAccessor
|
||||
{
|
||||
virtual void addFile(CanonPath path, std::string && contents) = 0;
|
||||
virtual SourcePath addFile(CanonPath path, std::string && contents) = 0;
|
||||
};
|
||||
|
||||
ref<MemoryInputAccessor> makeMemoryInputAccessor();
|
||||
|
|
Loading…
Reference in a new issue