Skip to content

Commit 7570de7

Browse files
authored
Merge pull request #493 from cachix/rename-nixfmt
nixfmt: deprecate `nixfmt` and redirect to `nixfmt-classic` or `nixfmt-rfc-style`
2 parents 4509ca6 + cbb1a98 commit 7570de7

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

modules/hooks.nix

+28-5
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,22 @@ in
846846
};
847847
};
848848
nixfmt = mkOption {
849-
description = "nixfmt hook";
849+
description = "Deprecated nixfmt hook";
850+
visible = false;
851+
type = types.submodule {
852+
imports = [ hookModule ];
853+
options.settings = {
854+
width =
855+
mkOption {
856+
type = types.nullOr types.int;
857+
description = "Line width.";
858+
default = null;
859+
};
860+
};
861+
};
862+
};
863+
nixfmt-classic = mkOption {
864+
description = "nixfmt (classic) hook";
850865
type = types.submodule {
851866
imports = [ hookModule ];
852867
options.settings = {
@@ -1721,6 +1736,11 @@ in
17211736
config.warnings =
17221737
lib.optional cfg.hooks.rome.enable ''
17231738
The hook `hooks.rome` has been renamed to `hooks.biome`.
1739+
''
1740+
++ lib.optional cfg.hooks.nixfmt.enable ''
1741+
The hook `hooks.nixfmt` has been renamed to `hooks.nixfmt-classic`.
1742+
1743+
The new RFC 166-style nixfmt is available as `hooks.nixfmt-rfc-style`.
17241744
'';
17251745

17261746
# PLEASE keep this sorted alphabetically.
@@ -2874,12 +2894,15 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
28742894
builtins.toString script;
28752895
files = "\\.nix$";
28762896
};
2877-
nixfmt =
2897+
# nixfmt was renamed to nixfmt-classic.
2898+
# The hook has been deprecated to free up the name for when the new RFC-style nixfmt becomes stable.
2899+
nixfmt = nixfmt-classic;
2900+
nixfmt-classic =
28782901
{
2879-
name = "nixfmt";
2880-
description = "Nix code prettifier.";
2902+
name = "nixfmt-classic";
2903+
description = "Nix code prettifier (classic).";
28812904
package = tools.nixfmt-classic;
2882-
entry = "${hooks.nixfmt.package}/bin/nixfmt ${lib.optionalString (hooks.nixfmt.settings.width != null) "--width=${toString hooks.nixfmt.settings.width}"}";
2905+
entry = "${hooks.nixfmt-classic.package}/bin/nixfmt ${lib.optionalString (hooks.nixfmt-classic.settings.width != null) "--width=${toString hooks.nixfmt-classic.settings.width}"}";
28832906
files = "\\.nix$";
28842907
};
28852908
nixfmt-rfc-style =

0 commit comments

Comments
 (0)