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 flake update` to update all flake inputs.
|
||||||
- Run `nix --option sandbox false build .#check -L` to run the flake checks.
|
- 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 `, 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)
|
- Run the application without installing: `nix run github:srid/haskell-template` (or `nix run .` from checkout)
|
||||||
- Common workflows
|
- Common workflows
|
||||||
|
|
19
flake.lock
generated
19
flake.lock
generated
|
@ -123,21 +123,22 @@
|
||||||
"haskell-flake": "haskell-flake",
|
"haskell-flake": "haskell-flake",
|
||||||
"mission-control": "mission-control",
|
"mission-control": "mission-control",
|
||||||
"nixpkgs": "nixpkgs_2",
|
"nixpkgs": "nixpkgs_2",
|
||||||
"treefmt-flake": "treefmt-flake"
|
"treefmt-nix": "treefmt-nix"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"treefmt-flake": {
|
"treefmt-nix": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1669929251,
|
"lastModified": 1671645275,
|
||||||
"narHash": "sha256-+qgCD89JyZhBNF4m/HuuVrpoRoXMTl5F60mJzr3QPNM=",
|
"narHash": "sha256-aHpd0f/WBO4a3kK7wy8tsp4iGTOGEAY3sL/ujOLkqw0=",
|
||||||
"owner": "srid",
|
"owner": "Platonic-Systems",
|
||||||
"repo": "treefmt-flake",
|
"repo": "treefmt-nix",
|
||||||
"rev": "86341cd4a0ce21556a348fd27a4797997d27be00",
|
"rev": "8280dec5403061434de195b81854d65e6613b5ca",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "srid",
|
"owner": "Platonic-Systems",
|
||||||
"repo": "treefmt-flake",
|
"ref": "flake-module",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
flake.nix
32
flake.nix
|
@ -4,7 +4,7 @@
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
haskell-flake.url = "github:srid/haskell-flake";
|
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";
|
flake-root.url = "github:srid/flake-root";
|
||||||
mission-control.url = "github:Platonic-Systems/mission-control";
|
mission-control.url = "github:Platonic-Systems/mission-control";
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
systems = nixpkgs.lib.systems.flakeExposed;
|
systems = nixpkgs.lib.systems.flakeExposed;
|
||||||
imports = [
|
imports = [
|
||||||
inputs.haskell-flake.flakeModule
|
inputs.haskell-flake.flakeModule
|
||||||
inputs.treefmt-flake.flakeModule
|
inputs.treefmt-nix.flakeModule
|
||||||
inputs.flake-root.flakeModule
|
inputs.flake-root.flakeModule
|
||||||
inputs.mission-control.flakeModule
|
inputs.mission-control.flakeModule
|
||||||
];
|
];
|
||||||
|
@ -25,7 +25,9 @@
|
||||||
packages = {
|
packages = {
|
||||||
haskell-template.root = ./.;
|
haskell-template.root = ./.;
|
||||||
};
|
};
|
||||||
buildTools = hp: { } // config.treefmt.formatters;
|
buildTools = hp: {
|
||||||
|
treefmt = config.treefmt.wrapper;
|
||||||
|
} // config.treefmt.programs;
|
||||||
# overrides = self: super: {}
|
# overrides = self: super: {}
|
||||||
hlsCheck.enable = true;
|
hlsCheck.enable = true;
|
||||||
hlintCheck.enable = true;
|
hlintCheck.enable = true;
|
||||||
|
@ -33,12 +35,22 @@
|
||||||
|
|
||||||
# Auto formatters. This also adds a flake check to ensure that the
|
# Auto formatters. This also adds a flake check to ensure that the
|
||||||
# source tree was auto formatted.
|
# source tree was auto formatted.
|
||||||
treefmt.formatters = {
|
treefmt.config = {
|
||||||
inherit (pkgs)
|
package = pkgs.treefmt;
|
||||||
nixpkgs-fmt;
|
projectRootFile = "flake.nix";
|
||||||
inherit (pkgs.haskellPackages)
|
|
||||||
cabal-fmt
|
programs.ormolu.enable = true;
|
||||||
fourmolu;
|
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.
|
# Dev shell scripts.
|
||||||
|
@ -60,7 +72,7 @@
|
||||||
};
|
};
|
||||||
fmt = {
|
fmt = {
|
||||||
description = "Format the source tree";
|
description = "Format the source tree";
|
||||||
exec = "${lib.getExe pkgs.treefmt}";
|
exec = "${lib.getExe config.treefmt.wrapper}";
|
||||||
category = "Dev Tools ";
|
category = "Dev Tools ";
|
||||||
};
|
};
|
||||||
run = {
|
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