Skip to content

Commit

Permalink
Merge pull request #493 from cachix/rename-nixfmt
Browse files Browse the repository at this point in the history
nixfmt: deprecate `nixfmt` and redirect to `nixfmt-classic` or `nixfmt-rfc-style`
  • Loading branch information
sandydoo authored Sep 5, 2024
2 parents 4509ca6 + cbb1a98 commit 7570de7
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,22 @@ in
};
};
nixfmt = mkOption {
description = "nixfmt hook";
description = "Deprecated nixfmt hook";
visible = false;
type = types.submodule {
imports = [ hookModule ];
options.settings = {
width =
mkOption {
type = types.nullOr types.int;
description = "Line width.";
default = null;
};
};
};
};
nixfmt-classic = mkOption {
description = "nixfmt (classic) hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
Expand Down Expand Up @@ -1721,6 +1736,11 @@ in
config.warnings =
lib.optional cfg.hooks.rome.enable ''
The hook `hooks.rome` has been renamed to `hooks.biome`.
''
++ lib.optional cfg.hooks.nixfmt.enable ''
The hook `hooks.nixfmt` has been renamed to `hooks.nixfmt-classic`.
The new RFC 166-style nixfmt is available as `hooks.nixfmt-rfc-style`.
'';

# PLEASE keep this sorted alphabetically.
Expand Down Expand Up @@ -2874,12 +2894,15 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
builtins.toString script;
files = "\\.nix$";
};
nixfmt =
# nixfmt was renamed to nixfmt-classic.
# The hook has been deprecated to free up the name for when the new RFC-style nixfmt becomes stable.
nixfmt = nixfmt-classic;
nixfmt-classic =
{
name = "nixfmt";
description = "Nix code prettifier.";
name = "nixfmt-classic";
description = "Nix code prettifier (classic).";
package = tools.nixfmt-classic;
entry = "${hooks.nixfmt.package}/bin/nixfmt ${lib.optionalString (hooks.nixfmt.settings.width != null) "--width=${toString hooks.nixfmt.settings.width}"}";
entry = "${hooks.nixfmt-classic.package}/bin/nixfmt ${lib.optionalString (hooks.nixfmt-classic.settings.width != null) "--width=${toString hooks.nixfmt-classic.settings.width}"}";
files = "\\.nix$";
};
nixfmt-rfc-style =
Expand Down

0 comments on commit 7570de7

Please sign in to comment.