mirror of
https://github.com/NixOS/nix
synced 2025-06-25 02:21:16 +02:00
Log warnings on IFD with new option
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This commit is contained in:
parent
74a107d364
commit
ce89c8c114
2 changed files with 23 additions and 5 deletions
|
@ -152,6 +152,16 @@ struct EvalSettings : Config
|
||||||
)"
|
)"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Setting<bool> traceImportFromDerivation{
|
||||||
|
this, false, "trace-import-from-derivation",
|
||||||
|
R"(
|
||||||
|
By default, Nix allows [Import from Derivation](@docroot@/language/import-from-derivation.md).
|
||||||
|
|
||||||
|
When this setting is `true`, Nix will log a warning indicating that it performed such an import.
|
||||||
|
This option has no effect if `allow-import-from-derivation` is disabled.
|
||||||
|
)"
|
||||||
|
};
|
||||||
|
|
||||||
Setting<bool> enableImportFromDerivation{
|
Setting<bool> enableImportFromDerivation{
|
||||||
this, true, "allow-import-from-derivation",
|
this, true, "allow-import-from-derivation",
|
||||||
R"(
|
R"(
|
||||||
|
|
|
@ -90,11 +90,19 @@ StringMap EvalState::realiseContext(const NixStringContext & context, StorePathS
|
||||||
|
|
||||||
if (drvs.empty()) return {};
|
if (drvs.empty()) return {};
|
||||||
|
|
||||||
if (isIFD && !settings.enableImportFromDerivation)
|
if (isIFD) {
|
||||||
error<IFDError>(
|
if (!settings.enableImportFromDerivation)
|
||||||
"cannot build '%1%' during evaluation because the option 'allow-import-from-derivation' is disabled",
|
error<IFDError>(
|
||||||
drvs.begin()->to_string(*store)
|
"cannot build '%1%' during evaluation because the option 'allow-import-from-derivation' is disabled",
|
||||||
).debugThrow();
|
drvs.begin()->to_string(*store)
|
||||||
|
).debugThrow();
|
||||||
|
|
||||||
|
if (settings.traceImportFromDerivation)
|
||||||
|
warn(
|
||||||
|
"built '%1%' during evaluation due to an import from derivation",
|
||||||
|
drvs.begin()->to_string(*store)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* Build/substitute the context. */
|
/* Build/substitute the context. */
|
||||||
std::vector<DerivedPath> buildReqs;
|
std::vector<DerivedPath> buildReqs;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue