mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
print type and value in "flake attr is not a derivation" errors
This turns errors like:
error: flake output attribute 'hydraJobs' is not a derivation or path
into errors like:
error: expected flake output attribute 'hydraJobs' to be a derivation or
path but found a set: { binaryTarball = «thunk»; build = «thunk»; etc> }
This change affects all InstallableFlake commands.
Source: 20981461d4
Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
This commit is contained in:
parent
e2182d07d9
commit
18ac6545fc
2 changed files with 25 additions and 2 deletions
18
doc/manual/rl-next/print-value-in-installable-flake-error.md
Normal file
18
doc/manual/rl-next/print-value-in-installable-flake-error.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
synopsis: New-cli flake commands that expect derivations now print the failing value and its type
|
||||
prs: 10778
|
||||
---
|
||||
|
||||
In errors like `flake output attribute 'nixosConfigurations.yuki.config' is not a derivation or path`, the message now includes the failing value and type.
|
||||
|
||||
Before:
|
||||
|
||||
```
|
||||
error: flake output attribute 'nixosConfigurations.yuki.config' is not a derivation or path
|
||||
````
|
||||
|
||||
After:
|
||||
|
||||
```
|
||||
error: expected flake output attribute 'nixosConfigurations.yuki.config' to be a derivation or path but found a set: { appstream = «thunk»; assertions = «thunk»; boot = { bcache = «thunk»; binfmt = «thunk»; binfmtMiscRegistrations = «thunk»; blacklistedKernelModules = «thunk»; bootMount = «thunk»; bootspec = «thunk»; cleanTmpDir = «thunk»; consoleLogLevel = «thunk»; «43 attributes elided» }; «48 attributes elided» }
|
||||
```
|
|
@ -106,9 +106,14 @@ DerivedPathsWithInfo InstallableFlake::toDerivedPaths()
|
|||
fmt("while evaluating the flake output attribute '%s'", attrPath)))
|
||||
{
|
||||
return { *derivedPathWithInfo };
|
||||
} else {
|
||||
throw Error(
|
||||
"expected flake output attribute '%s' to be a derivation or path but found %s: %s",
|
||||
attrPath,
|
||||
showType(v),
|
||||
ValuePrinter(*this->state, v, errorPrintOptions)
|
||||
);
|
||||
}
|
||||
else
|
||||
throw Error("flake output attribute '%s' is not a derivation or path", attrPath);
|
||||
}
|
||||
|
||||
auto drvPath = attr->forceDerivation();
|
||||
|
|
Loading…
Reference in a new issue