Skip to content

Commit

Permalink
Merge pull request #304 from numtide/readme-supported-versions
Browse files Browse the repository at this point in the history
readme supported versions
  • Loading branch information
zimbatm authored Feb 4, 2025
2 parents b49eb4a + 79fbd2c commit 81b5c50
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@ That mostly means, for the given formatter:
- You get precedence if any decisions need to be made.
- Getting pinged if any issue is being found.

## Supported Nix versions

treefmt-nix works with all known Nix version.

If you rely on flakes and `nix fmt`, we recommend running Nix 2.25 or Lix 2.92
or later. See https://github.com/NixOS/nix/pull/11438

## Commercial support

Looking for help or customization?
Expand Down
39 changes: 38 additions & 1 deletion programs/nixfmt.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{ mkFormatterModule, ... }:
{
lib,
config,
mkFormatterModule,
...
}:
let
cfg = config.programs.nixfmt;
in
{
meta.maintainers = [ ];

Expand All @@ -9,4 +17,33 @@
includes = [ "*.nix" ];
})
];

options.programs.nixfmt = {
strict = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Enable a stricter formatting mode that isn't influenced
as much by how the input is formatted.
'';
};

width = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
example = 120;
description = ''
Maximum width in characters [default: 100]
'';
};
};

config = lib.mkIf cfg.enable {
settings.formatter.nixfmt.options =
lib.optionals (!isNull cfg.width) [
"--width"
(toString cfg.width)
]
++ lib.optional cfg.strict "--strict";
};
}

0 comments on commit 81b5c50

Please sign in to comment.