Skip to content

flake-module: enable treefmt as default formatter for the flake #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cut_body_after = "" # don't include text from the PR body in the merge commit message
status = [
"Evaluate flake.nix"
]
23 changes: 13 additions & 10 deletions flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@ in

Use `config.treefmt.build.wrapper` to get access to the resulting treefmt
package based on this configuration.

The following sets treefmt up as the default formatter
used by the `nix fmt` command:

```
perSystem = { config, ... }: {
formatter = config.treefmt.build.wrapper;
};
```

By default treefmt-nix will set the formatter.<system> attribute of the flake,
used by the `nix fmt` command.
'';
type = types.submoduleWith {
modules = (import ./.).all-modules pkgs;
modules = (import ./.).all-modules pkgs ++ [{
options.flakeFormatter = lib.mkOption {
type = types.bool;
default = true;
description = lib.mdDoc ''
Enables `treefmt` the default formatter used by the `nix fmt` command
'';
};
}];
};
};
config = {
checks.treefmt = config.treefmt.build.check self;
formatter = lib.mkIf config.treefmt.flakeFormatter (lib.mkDefault config.treefmt.build.wrapper);
};
});
};
Expand Down