diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 97f4d911c..aa0e18533 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -1024,13 +1024,17 @@ struct CmdFlakeShow : FlakeCommand, MixJSON (attrPath.size() == 2 && attrPath[0] == "defaultApp") || (attrPath.size() == 3 && attrPath[0] == "apps")) { - auto aType = visitor.maybeGetAttr("type"); - if (!aType || aType->getString() != "app") - throw EvalError("not an app definition"); - if (json) { - j.emplace("type", "app"); - } else { - logger->cout("%s: app", headerPrefix); + if (visitor.isDerivation()) + showDerivation(); + else { + auto aType = visitor.maybeGetAttr("type"); + if (!aType || aType->getString() != "app") + throw EvalError("not an app definition"); + if (json) { + j.emplace("type", "app"); + } else { + logger->cout("%s: app", headerPrefix); + } } } diff --git a/tests/flakes.sh b/tests/flakes.sh index 9e10322b9..0759a1772 100644 --- a/tests/flakes.sh +++ b/tests/flakes.sh @@ -380,6 +380,11 @@ cat > $templatesDir/trivial/flake.nix <