mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 16:26:18 +02:00
nix flake check: Check defaultPackage, devShell and packages
This commit is contained in:
parent
e0aaf05f4f
commit
0e32b32fa3
1 changed files with 26 additions and 12 deletions
|
@ -262,6 +262,19 @@ struct CmdFlakeCheck : FlakeCommand, MixJSON
|
||||||
auto state = getEvalState();
|
auto state = getEvalState();
|
||||||
auto flake = resolveFlake();
|
auto flake = resolveFlake();
|
||||||
|
|
||||||
|
auto checkDerivation = [&](const std::string & attrPath, Value & v) {
|
||||||
|
try {
|
||||||
|
auto drvInfo = getDerivation(*state, v, false);
|
||||||
|
if (!drvInfo)
|
||||||
|
throw Error("flake attribute '%s' is not a derivation", attrPath);
|
||||||
|
// FIXME: check meta attributes
|
||||||
|
return drvInfo->queryDrvPath();
|
||||||
|
} catch (Error & e) {
|
||||||
|
e.addPrefix(fmt("while checking flake attribute '" ANSI_BOLD "%s" ANSI_NORMAL "':\n", attrPath));
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
PathSet drvPaths;
|
PathSet drvPaths;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -281,20 +294,21 @@ struct CmdFlakeCheck : FlakeCommand, MixJSON
|
||||||
|
|
||||||
if (name == "checks") {
|
if (name == "checks") {
|
||||||
state->forceAttrs(vProvide);
|
state->forceAttrs(vProvide);
|
||||||
for (auto & aCheck : *vProvide.attrs) {
|
for (auto & aCheck : *vProvide.attrs)
|
||||||
try {
|
drvPaths.insert(checkDerivation(
|
||||||
auto drvInfo = getDerivation(*state, *aCheck.value, false);
|
name + "." + (std::string) aCheck.name, *aCheck.value));
|
||||||
if (!drvInfo)
|
|
||||||
throw Error("flake output 'check.%s' is not a derivation", aCheck.name);
|
|
||||||
drvPaths.insert(drvInfo->queryDrvPath());
|
|
||||||
// FIXME: check meta attributes?
|
|
||||||
} catch (Error & e) {
|
|
||||||
e.addPrefix(fmt("while checking flake check '" ANSI_BOLD "%s" ANSI_NORMAL "':\n", aCheck.name));
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (name == "packages") {
|
||||||
|
state->forceAttrs(vProvide);
|
||||||
|
for (auto & aCheck : *vProvide.attrs)
|
||||||
|
checkDerivation(
|
||||||
|
name + "." + (std::string) aCheck.name, *aCheck.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (name == "defaultPackage" || name == "devShell")
|
||||||
|
checkDerivation(name, vProvide);
|
||||||
|
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addPrefix(fmt("while checking flake output '" ANSI_BOLD "%s" ANSI_NORMAL "':\n", name));
|
e.addPrefix(fmt("while checking flake output '" ANSI_BOLD "%s" ANSI_NORMAL "':\n", name));
|
||||||
throw;
|
throw;
|
||||||
|
|
Loading…
Reference in a new issue