mirror of
https://github.com/NixOS/nix.git
synced 2025-12-14 21:11:04 +01:00
Merge pull request #14739 from Mic92/nix-develop
turn 'derivation has incorrect deferred output' into warning
This commit is contained in:
commit
28107db1bb
2 changed files with 20 additions and 9 deletions
|
|
@ -174,6 +174,7 @@ TEST_F(FillInOutputPathsTest, throwsOnIncorrectInputAddressedPath)
|
||||||
ASSERT_THROW(drv.fillInOutputPaths(*store), Error);
|
ASSERT_THROW(drv.fillInOutputPaths(*store), Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
TEST_F(FillInOutputPathsTest, throwsOnIncorrectEnvVar)
|
TEST_F(FillInOutputPathsTest, throwsOnIncorrectEnvVar)
|
||||||
{
|
{
|
||||||
auto wrongPath = StorePath{"c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-wrong-name"};
|
auto wrongPath = StorePath{"c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-wrong-name"};
|
||||||
|
|
@ -195,6 +196,7 @@ TEST_F(FillInOutputPathsTest, throwsOnIncorrectEnvVar)
|
||||||
|
|
||||||
ASSERT_THROW(drv.fillInOutputPaths(*store), Error);
|
ASSERT_THROW(drv.fillInOutputPaths(*store), Error);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST_F(FillInOutputPathsTest, preservesDeferredWithInputDrvs)
|
TEST_F(FillInOutputPathsTest, preservesDeferredWithInputDrvs)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1230,7 +1230,7 @@ static void processDerivationOutputPaths(Store & store, auto && drv, std::string
|
||||||
std::optional<DrvHash> hashesModulo;
|
std::optional<DrvHash> hashesModulo;
|
||||||
|
|
||||||
for (auto & [outputName, output] : drv.outputs) {
|
for (auto & [outputName, output] : drv.outputs) {
|
||||||
auto envHasRightPath = [&](const StorePath & actual) {
|
auto envHasRightPath = [&](const StorePath & actual, bool isDeferred = false) {
|
||||||
if constexpr (fillIn) {
|
if constexpr (fillIn) {
|
||||||
auto j = drv.env.find(outputName);
|
auto j = drv.env.find(outputName);
|
||||||
/* Fill in mode: fill in missing or empty environment
|
/* Fill in mode: fill in missing or empty environment
|
||||||
|
|
@ -1248,12 +1248,20 @@ static void processDerivationOutputPaths(Store & store, auto && drv, std::string
|
||||||
"derivation has missing environment variable '%s', should be '%s' but is not present",
|
"derivation has missing environment variable '%s', should be '%s' but is not present",
|
||||||
outputName,
|
outputName,
|
||||||
store.printStorePath(actual));
|
store.printStorePath(actual));
|
||||||
if (j->second != store.printStorePath(actual))
|
if (j->second != store.printStorePath(actual)) {
|
||||||
throw Error(
|
if (isDeferred)
|
||||||
"derivation has incorrect environment variable '%s', should be '%s' but is actually '%s'",
|
warn(
|
||||||
outputName,
|
"derivation has incorrect environment variable '%s', should be '%s' but is actually '%s'\nThis will be an error in future versions of Nix; compatibility of CA derivations will be broken.",
|
||||||
store.printStorePath(actual),
|
outputName,
|
||||||
j->second);
|
store.printStorePath(actual),
|
||||||
|
j->second);
|
||||||
|
else
|
||||||
|
throw Error(
|
||||||
|
"derivation has incorrect environment variable '%s', should be '%s' but is actually '%s'",
|
||||||
|
outputName,
|
||||||
|
store.printStorePath(actual),
|
||||||
|
j->second);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
auto hash = [&]<typename Output>(const Output & outputVariant) {
|
auto hash = [&]<typename Output>(const Output & outputVariant) {
|
||||||
if (!hashesModulo) {
|
if (!hashesModulo) {
|
||||||
|
|
@ -1287,8 +1295,9 @@ static void processDerivationOutputPaths(Store & store, auto && drv, std::string
|
||||||
else
|
else
|
||||||
/* Validation mode: deferred outputs
|
/* Validation mode: deferred outputs
|
||||||
should have been filled in */
|
should have been filled in */
|
||||||
throw Error(
|
warn(
|
||||||
"derivation has incorrect deferred output, should be '%s'", store.printStorePath(outPath));
|
"derivation has incorrect deferred output, should be '%s'.\nThis will be an error in future versions of Nix; compatibility of CA derivations will be broken.",
|
||||||
|
store.printStorePath(outPath));
|
||||||
} else {
|
} else {
|
||||||
/* Will never happen, based on where
|
/* Will never happen, based on where
|
||||||
`hash` is called. */
|
`hash` is called. */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue