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.
27 lines
511 B
Nix
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);
|
|
}
|