Files
Matt SturgeonandGitHub 0858f1bc43 treefmt: refactor withConfig and buildConfig to use evalConfig (#406685)
Introduces a new modules-based implementation that is used by both
`withConfig` and `buildConfig`. 

Previously we used a module eval for `settings`. This PR makes it so
that all args passed to `withConfig` are now module options. `settings`
is now a submodule of the wider `evalConfig` configuration.

As well as being a better overall design (IMO), using a module eval
enables adding additional options in the future. E.g. we could add
`programs` options similar to those maintained by treefmt-nix.
2025-05-19 17:22:32 +02:00

27 lines
511 B
Nix

{
lib,
pkgs,
config,
modulesPath,
...
}:
let
settingsFormat = pkgs.formats.toml { };
in
{
options.settings = lib.mkOption {
type = lib.types.submoduleWith {
specialArgs = { inherit modulesPath; };
modules = [
{ freeformType = settingsFormat.type; }
];
};
default = { };
description = ''
Settings used to build a treefmt config file.
'';
};
config.configFile = lib.mkOptionDefault (settingsFormat.generate "treefmt.toml" config.settings);
}