Require formatters to be packages

Because of 9b41239d8f, a formatter can
no longer be a package *or* an app. So let's require it to be a
package for now.
This commit is contained in:
Eelco Dolstra 2022-04-19 20:48:13 +02:00
parent 48a467f2b9
commit c9e58aa5ff
3 changed files with 9 additions and 8 deletions

View file

@ -35,7 +35,7 @@ struct InstallableDerivedPath : Installable
/** /**
* Return the rewrites that are needed to resolve a string whose context is * Return the rewrites that are needed to resolve a string whose context is
* included in `dependencies` * included in `dependencies`.
*/ */
StringPairs resolveRewrites(Store & store, const BuiltPaths dependencies) StringPairs resolveRewrites(Store & store, const BuiltPaths dependencies)
{ {
@ -51,7 +51,7 @@ StringPairs resolveRewrites(Store & store, const BuiltPaths dependencies)
} }
/** /**
* Resolve the given string assuming the given context * Resolve the given string assuming the given context.
*/ */
std::string resolveString(Store & store, const std::string & toResolve, const BuiltPaths dependencies) std::string resolveString(Store & store, const std::string & toResolve, const BuiltPaths dependencies)
{ {

View file

@ -1038,7 +1038,7 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
} }
else if ( else if (
(attrPath.size() == 2 && (attrPath[0] == "defaultPackage" || attrPath[0] == "devShell")) (attrPath.size() == 2 && (attrPath[0] == "defaultPackage" || attrPath[0] == "devShell" || attrPath[0] == "formatter"))
|| (attrPath.size() == 3 && (attrPath[0] == "checks" || attrPath[0] == "packages" || attrPath[0] == "devShells")) || (attrPath.size() == 3 && (attrPath[0] == "checks" || attrPath[0] == "packages" || attrPath[0] == "devShells"))
) )
{ {
@ -1071,7 +1071,6 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
else if ( else if (
(attrPath.size() == 2 && attrPath[0] == "defaultApp") || (attrPath.size() == 2 && attrPath[0] == "defaultApp") ||
(attrPath.size() == 2 && attrPath[0] == "formatter") ||
(attrPath.size() == 3 && attrPath[0] == "apps")) (attrPath.size() == 3 && attrPath[0] == "apps"))
{ {
auto aType = visitor.maybeGetAttr("type"); auto aType = visitor.maybeGetAttr("type");

View file

@ -14,9 +14,11 @@ nix fmt --help | grep "Format"
cat << EOF > flake.nix cat << EOF > flake.nix
{ {
outputs = _: { outputs = _: {
formatter.$system = { formatter.$system =
type = "app"; with import ./config.nix;
program = ./fmt.simple.sh; mkDerivation {
name = "formatter";
buildCommand = "mkdir -p \$out/bin; cp \${./fmt.simple.sh} \$out/bin/formatter";
}; };
}; };
} }