Revamp treefmt use via flake-parts
module (#75)
Get rid of `treefmt.toml` as that is nixified.
This commit is contained in:
parent
3a30ce4c5a
commit
e53a65ece6
4 changed files with 33 additions and 41 deletions
|
@ -21,7 +21,7 @@ For details, see: https://srid.ca/haskell-template/start
|
|||
|
||||
- Run `nix flake update` to update all flake inputs.
|
||||
- Run `nix --option sandbox false build .#check -L` to run the flake checks.
|
||||
- Run `, fmt` in nix shell to autoformat the project. This uses [treefmt](https://github.com/numtide/treefmt), which uses `./treefmt.toml` (where fourmolu and nixpkgs-fmt are specified).
|
||||
- Run `, fmt` in nix shell to autoformat the project. This uses [treefmt](https://github.com/numtide/treefmt).
|
||||
- Run `, docs` to start Hoogle with packages in your cabal file.
|
||||
- Run the application without installing: `nix run github:srid/haskell-template` (or `nix run .` from checkout)
|
||||
- Common workflows
|
||||
|
|
19
flake.lock
generated
19
flake.lock
generated
|
@ -123,21 +123,22 @@
|
|||
"haskell-flake": "haskell-flake",
|
||||
"mission-control": "mission-control",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"treefmt-flake": "treefmt-flake"
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"treefmt-flake": {
|
||||
"treefmt-nix": {
|
||||
"locked": {
|
||||
"lastModified": 1669929251,
|
||||
"narHash": "sha256-+qgCD89JyZhBNF4m/HuuVrpoRoXMTl5F60mJzr3QPNM=",
|
||||
"owner": "srid",
|
||||
"repo": "treefmt-flake",
|
||||
"rev": "86341cd4a0ce21556a348fd27a4797997d27be00",
|
||||
"lastModified": 1671645275,
|
||||
"narHash": "sha256-aHpd0f/WBO4a3kK7wy8tsp4iGTOGEAY3sL/ujOLkqw0=",
|
||||
"owner": "Platonic-Systems",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "8280dec5403061434de195b81854d65e6613b5ca",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "srid",
|
||||
"repo": "treefmt-flake",
|
||||
"owner": "Platonic-Systems",
|
||||
"ref": "flake-module",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
|
|
32
flake.nix
32
flake.nix
|
@ -4,7 +4,7 @@
|
|||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
haskell-flake.url = "github:srid/haskell-flake";
|
||||
treefmt-flake.url = "github:srid/treefmt-flake";
|
||||
treefmt-nix.url = "github:Platonic-Systems/treefmt-nix/flake-module"; # https://github.com/numtide/treefmt-nix/pull/14
|
||||
flake-root.url = "github:srid/flake-root";
|
||||
mission-control.url = "github:Platonic-Systems/mission-control";
|
||||
};
|
||||
|
@ -14,7 +14,7 @@
|
|||
systems = nixpkgs.lib.systems.flakeExposed;
|
||||
imports = [
|
||||
inputs.haskell-flake.flakeModule
|
||||
inputs.treefmt-flake.flakeModule
|
||||
inputs.treefmt-nix.flakeModule
|
||||
inputs.flake-root.flakeModule
|
||||
inputs.mission-control.flakeModule
|
||||
];
|
||||
|
@ -25,7 +25,9 @@
|
|||
packages = {
|
||||
haskell-template.root = ./.;
|
||||
};
|
||||
buildTools = hp: { } // config.treefmt.formatters;
|
||||
buildTools = hp: {
|
||||
treefmt = config.treefmt.wrapper;
|
||||
} // config.treefmt.programs;
|
||||
# overrides = self: super: {}
|
||||
hlsCheck.enable = true;
|
||||
hlintCheck.enable = true;
|
||||
|
@ -33,12 +35,22 @@
|
|||
|
||||
# Auto formatters. This also adds a flake check to ensure that the
|
||||
# source tree was auto formatted.
|
||||
treefmt.formatters = {
|
||||
inherit (pkgs)
|
||||
nixpkgs-fmt;
|
||||
inherit (pkgs.haskellPackages)
|
||||
cabal-fmt
|
||||
fourmolu;
|
||||
treefmt.config = {
|
||||
package = pkgs.treefmt;
|
||||
projectRootFile = "flake.nix";
|
||||
|
||||
programs.ormolu.enable = true;
|
||||
programs.ormolu.package = pkgs.haskellPackages.fourmolu;
|
||||
settings.formatter.ormolu = {
|
||||
options = [
|
||||
"--ghc-opt"
|
||||
"-XImportQualifiedPost"
|
||||
];
|
||||
};
|
||||
|
||||
programs.nixpkgs-fmt.enable = true;
|
||||
|
||||
programs.cabal-fmt.enable = true;
|
||||
};
|
||||
|
||||
# Dev shell scripts.
|
||||
|
@ -60,7 +72,7 @@
|
|||
};
|
||||
fmt = {
|
||||
description = "Format the source tree";
|
||||
exec = "${lib.getExe pkgs.treefmt}";
|
||||
exec = "${lib.getExe config.treefmt.wrapper}";
|
||||
category = "Dev Tools ";
|
||||
};
|
||||
run = {
|
||||
|
|
21
treefmt.toml
21
treefmt.toml
|
@ -1,21 +0,0 @@
|
|||
[formatter.haskell]
|
||||
command = "fourmolu"
|
||||
options = [
|
||||
"--ghc-opt",
|
||||
"-XImportQualifiedPost",
|
||||
"--ghc-opt",
|
||||
"-XTypeApplications",
|
||||
"--mode",
|
||||
"inplace",
|
||||
"--check-idempotence",
|
||||
]
|
||||
includes = ["*.hs"]
|
||||
|
||||
[formatter.nix]
|
||||
command = "nixpkgs-fmt"
|
||||
includes = ["*.nix"]
|
||||
|
||||
[formatter.cabal]
|
||||
command = "cabal-fmt"
|
||||
options = ["--inplace"]
|
||||
includes = ["*.cabal"]
|
Loading…
Reference in a new issue