2022-09-19 14:59:49 +00:00
|
|
|
{ config, lib, flake-parts-lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib)
|
2022-11-13 10:50:16 +00:00
|
|
|
filterAttrs
|
|
|
|
mapAttrs
|
2022-09-19 14:59:49 +00:00
|
|
|
mkOption
|
2022-11-13 10:50:16 +00:00
|
|
|
optionalAttrs
|
2022-09-19 14:59:49 +00:00
|
|
|
types
|
|
|
|
;
|
|
|
|
inherit (flake-parts-lib)
|
2022-11-13 10:50:16 +00:00
|
|
|
mkSubmoduleOptions
|
|
|
|
mkPerSystemOption
|
2022-09-19 14:59:49 +00:00
|
|
|
;
|
|
|
|
in
|
2022-11-13 10:50:16 +00:00
|
|
|
{
|
|
|
|
options = {
|
|
|
|
flake = mkSubmoduleOptions {
|
|
|
|
formatter = mkOption {
|
|
|
|
type = types.lazyAttrsOf types.package;
|
|
|
|
default = { };
|
|
|
|
description = ''
|
2022-11-13 10:51:15 +00:00
|
|
|
An attribute set of per system a package used by [`nix fmt`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-fmt.html).
|
2022-11-13 10:50:16 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-05-29 17:52:03 +00:00
|
|
|
perSystem = mkPerSystemOption {
|
2022-11-13 10:50:16 +00:00
|
|
|
_file = ./formatter.nix;
|
|
|
|
options = {
|
|
|
|
formatter = mkOption {
|
|
|
|
type = types.nullOr types.package;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
2022-11-13 10:51:15 +00:00
|
|
|
A package used by [`nix fmt`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-fmt.html).
|
2022-11-13 10:50:16 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2023-05-29 17:52:03 +00:00
|
|
|
};
|
2022-11-13 10:50:16 +00:00
|
|
|
};
|
|
|
|
config = {
|
|
|
|
flake.formatter =
|
|
|
|
mapAttrs
|
|
|
|
(k: v: v.formatter)
|
|
|
|
(filterAttrs
|
|
|
|
(k: v: v.formatter != null)
|
|
|
|
config.allSystems
|
|
|
|
);
|
|
|
|
|
|
|
|
perInput = system: flake:
|
|
|
|
optionalAttrs (flake?formatter.${system}) {
|
|
|
|
formatter = flake.formatter.${system};
|
|
|
|
};
|
|
|
|
|
2022-09-19 14:59:49 +00:00
|
|
|
};
|
|
|
|
}
|