Switch to treefmt; resolves #283

This commit is contained in:
Sridhar Ratnakumar 2022-05-04 16:24:34 -04:00
parent c94f12580f
commit 2fbd9dbe57
5 changed files with 26 additions and 56 deletions

View file

@ -16,6 +16,12 @@ jobs:
install_options: "--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve"
extra_nix_config: |
experimental-features = nix-command flakes
- name: Cache Nix dependencies
run: |
nix develop -j 4 -c echo
- name: Format check
run: |
nix develop -j auto -c treefmt -- --fail-on-change
- name: Build
id: build
run: |

View file

@ -5,6 +5,7 @@
"haskell.haskell",
"arrterian.nix-env-selector",
"bbenoist.nix",
"jnoortheen.nix-ide"
"jnoortheen.nix-ide",
"tamasfe.even-better-toml"
]
}
}

38
flake.lock generated
View file

@ -31,43 +31,6 @@
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"lint-utils": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1650427214,
"narHash": "sha256-9m66rRSSM614ocRXNPAArwnrS6zzCQYYhd3nw8g4QUg=",
"ref": "overengineered",
"rev": "5555def5a25c5437834c06cbe79b3945916ec59f",
"revCount": 28,
"type": "git",
"url": "https://gitlab.homotopic.tech/nix/lint-utils.git"
},
"original": {
"ref": "overengineered",
"type": "git",
"url": "https://gitlab.homotopic.tech/nix/lint-utils.git"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1651024496,
@ -88,7 +51,6 @@
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"lint-utils": "lint-utils",
"nixpkgs": "nixpkgs"
}
}

View file

@ -8,12 +8,6 @@
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
flake-compat.inputs.nixpkgs.follows = "nixpkgs";
lint-utils = {
type = "git";
url = "https://gitlab.homotopic.tech/nix/lint-utils.git";
ref = "overengineered"; # https://gitlab.homotopic.tech/nix/lint-utils/-/merge_requests/4
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs:
@ -39,6 +33,7 @@
fourmolu
hlint
pkgs.nixpkgs-fmt
pkgs.treefmt
];
project = returnShellEnv:
@ -64,15 +59,6 @@
(optionals returnShellEnv shellDeps))
];
};
lintSpec = {
nixpkgs-fmt = { };
cabal-fmt = { };
# hlint = { };
fourmolu = {
ghcOpts = "-o-XTypeApplications -o-XImportQualifiedPost";
};
};
in
{
# Used by `nix build ...`
@ -85,7 +71,6 @@
type = "app";
program = "${inputs.self.packages.${system}.default}/bin/haskell-template";
};
format = inputs.lint-utils.mkApp.${system} lintSpec;
};
# Used by `nix develop ...`
devShells = {

16
treefmt.toml Normal file
View file

@ -0,0 +1,16 @@
[formatter.haskell]
command = "fourmolu"
options = [
"--ghc-opt",
"-XImportQualifiedPost",
"--ghc-opt",
"-XTypeApplications",
"--mode",
"inplace",
"--check-idempotence",
]
includes = ["*.hs"]
[formatter.nix]
command = "nixpkgs-fmt"
includes = ["*.nix"]