Switch to declarative linters

Resolves #8
This commit is contained in:
Sridhar Ratnakumar 2022-03-30 15:12:35 -04:00
parent 357b9fafda
commit 0f37d0ef05
3 changed files with 23 additions and 33 deletions

12
flake.lock generated
View file

@ -54,16 +54,16 @@
]
},
"locked": {
"lastModified": 1648246591,
"narHash": "sha256-GDyLjj64sA65MPMlOtzs5DHPK4O5O8u6jMYKiGHgaPU=",
"ref": "master",
"rev": "3a4289e086d48b409c8c6eb51de1d9e405c7f379",
"revCount": 20,
"lastModified": 1648667273,
"narHash": "sha256-eQUb40xDyv0Ye3oMzGz6tcHPF9y9Xhq1QksV9h7uEDk=",
"ref": "spec-type",
"rev": "4648a98d91f754ae0f7a3d035a1aaa871eb1b4fc",
"revCount": 34,
"type": "git",
"url": "https://gitlab.homotopic.tech/nix/lint-utils.git"
},
"original": {
"ref": "master",
"ref": "spec-type",
"type": "git",
"url": "https://gitlab.homotopic.tech/nix/lint-utils.git"
}

View file

@ -11,7 +11,7 @@
lint-utils = {
type = "git";
url = "https://gitlab.homotopic.tech/nix/lint-utils.git";
ref = "master";
ref = "spec-type"; # https://gitlab.homotopic.tech/nix/lint-utils/-/merge_requests/4
inputs.nixpkgs.follows = "nixpkgs";
};
};
@ -25,7 +25,6 @@
# Change GHC version here. To get the appropriate value, run:
# nix-env -f "<nixpkgs>" -qaP -A haskell.compiler
hp = pkgs.haskellPackages; # pkgs.haskell.packages.ghc921;
haskellFormatter = "fourmoluStandardGhc8107"; # The formatter to use from inputs.lint-utils
project = returnShellEnv:
hp.developPackage {
@ -53,24 +52,20 @@
]);
};
lintSpec = {
nixpkgs-fmt = { };
cabal-fmt = { };
fourmolu = {
ghcOpts = "-o-XTypeApplications -o-XImportQualifiedPost";
};
};
# Checks the shell script using ShellCheck
checkedShellScript = name: text:
(pkgs.writeShellApplication {
inherit name text;
}) + "/bin/${name}";
# Concat a list of Flake apps to produce a new app that runs all of them
# in sequence.
concatApps = apps:
{
type = "app";
program = checkedShellScript "concatApps"
(pkgs.lib.strings.concatMapStringsSep
"\n"
(app: app.program)
apps);
};
in
{
# Used by `nix build` & `nix run` (prod exe)
@ -80,18 +75,13 @@
# Used by `nix run ...`
apps = {
format = concatApps [
inputs.lint-utils.apps.${system}.${haskellFormatter}
inputs.lint-utils.apps.${system}.cabal-fmt
inputs.lint-utils.apps.${system}.nixpkgs-fmt
];
format = inputs.lint-utils.mkApp.${system} lintSpec;
};
# Used by `nix flake check` (but see next attribute)
checks = {
format-haskell = inputs.lint-utils.linters.${system}.${haskellFormatter} ./.;
format-cabal = inputs.lint-utils.linters.${system}.cabal-fmt ./.;
format-nix = inputs.lint-utils.linters.${system}.nixpkgs-fmt ./.;
checks =
inputs.lint-utils.mkChecks.${system} lintSpec ./.
// {
hls = checkedShellScript "hls" "${hp.haskell-language-server}/bin/haskell-language-server";
};

View file

@ -1,6 +1,6 @@
module Main where
import Main.Utf8 (withUtf8)
import Main.Utf8 qualified as Utf8
{- |
Main entry point.
@ -11,5 +11,5 @@ import Main.Utf8 (withUtf8)
main :: IO ()
main = do
-- For withUtf8, see https://serokell.io/blog/haskell-with-utf8
withUtf8 $ do
Utf8.withUtf8 $ do
putStrLn "Hello 🌎"