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" install_options: "--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve"
extra_nix_config: | extra_nix_config: |
experimental-features = nix-command flakes 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 - name: Build
id: build id: build
run: | run: |

View file

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

38
flake.lock generated
View file

@ -31,43 +31,6 @@
"type": "github" "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1651024496, "lastModified": 1651024496,
@ -88,7 +51,6 @@
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"lint-utils": "lint-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View file

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