Skip to content

Commit c117283

Browse files
bors[bot]Mic92
andauthored
Merge #29
29: flake-module: enable treefmt as default formatter for the flake r=Mic92 a=Mic92 Co-authored-by: Jörg Thalheim <[email protected]>
2 parents 0e0a870 + ed9ca4a commit c117283

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

bors.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cut_body_after = "" # don't include text from the PR body in the merge commit message
2+
status = [
3+
"Evaluate flake.nix"
4+
]

flake-module.nix

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,25 @@ in
1616
1717
Use `config.treefmt.build.wrapper` to get access to the resulting treefmt
1818
package based on this configuration.
19-
20-
The following sets treefmt up as the default formatter
21-
used by the `nix fmt` command:
22-
23-
```
24-
perSystem = { config, ... }: {
25-
formatter = config.treefmt.build.wrapper;
26-
};
27-
```
19+
20+
By default treefmt-nix will set the formatter.<system> attribute of the flake,
21+
used by the `nix fmt` command.
2822
'';
2923
type = types.submoduleWith {
30-
modules = (import ./.).all-modules pkgs;
24+
modules = (import ./.).all-modules pkgs ++ [{
25+
options.flakeFormatter = lib.mkOption {
26+
type = types.bool;
27+
default = true;
28+
description = lib.mdDoc ''
29+
Enables `treefmt` the default formatter used by the `nix fmt` command
30+
'';
31+
};
32+
}];
3133
};
3234
};
3335
config = {
3436
checks.treefmt = config.treefmt.build.check self;
37+
formatter = lib.mkIf config.treefmt.flakeFormatter (lib.mkDefault config.treefmt.build.wrapper);
3538
};
3639
});
3740
};

0 commit comments

Comments
 (0)