mirror of
https://github.com/NixOS/nix.git
synced 2025-11-24 11:19:35 +01:00
Make nix flake show less strict wrt what apps can be
Allow `apps.foo` and `defaultApp` to be a plain derivation like `nix run` does. Fix #5560
This commit is contained in:
parent
1f7584d24c
commit
14cd643375
2 changed files with 16 additions and 7 deletions
|
|
@ -1024,6 +1024,9 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
||||||
(attrPath.size() == 2 && attrPath[0] == "defaultApp") ||
|
(attrPath.size() == 2 && attrPath[0] == "defaultApp") ||
|
||||||
(attrPath.size() == 3 && attrPath[0] == "apps"))
|
(attrPath.size() == 3 && attrPath[0] == "apps"))
|
||||||
{
|
{
|
||||||
|
if (visitor.isDerivation())
|
||||||
|
showDerivation();
|
||||||
|
else {
|
||||||
auto aType = visitor.maybeGetAttr("type");
|
auto aType = visitor.maybeGetAttr("type");
|
||||||
if (!aType || aType->getString() != "app")
|
if (!aType || aType->getString() != "app")
|
||||||
throw EvalError("not an app definition");
|
throw EvalError("not an app definition");
|
||||||
|
|
@ -1033,6 +1036,7 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
||||||
logger->cout("%s: app", headerPrefix);
|
logger->cout("%s: app", headerPrefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if (
|
else if (
|
||||||
(attrPath.size() == 1 && attrPath[0] == "defaultTemplate") ||
|
(attrPath.size() == 1 && attrPath[0] == "defaultTemplate") ||
|
||||||
|
|
|
||||||
|
|
@ -380,6 +380,11 @@ cat > $templatesDir/trivial/flake.nix <<EOF
|
||||||
outputs = { self, nixpkgs }: {
|
outputs = { self, nixpkgs }: {
|
||||||
packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
|
packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
|
||||||
defaultPackage.x86_64-linux = self.packages.x86_64-linux.hello;
|
defaultPackage.x86_64-linux = self.packages.x86_64-linux.hello;
|
||||||
|
apps.x86_64-linux.helloWorld = {
|
||||||
|
type = "app";
|
||||||
|
program = "\${nixpkgs.legacyPackages.x86_64-linux.hello}/bin/hello";
|
||||||
|
};
|
||||||
|
apps.x86_64-linux.helloWorld2 = nixpkgs.legacyPackages.x86_64-linux.hello;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue