Skip to content

Commit

Permalink
feat: Add fourmolu and hlint checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sgillespie committed Jun 17, 2023
1 parent 5946f0c commit 0d47b79
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ jobs:
name: sgillespie
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build
- run: nix flake check --allow-import-from-derivation
6 changes: 3 additions & 3 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Main where

import qualified MyLib (someFunc)
import MyLib qualified (someFunc)

main :: IO ()
main = do
putStrLn "Hello, Haskell!"
MyLib.someFunc
putStrLn "Hello, Haskell!"
MyLib.someFunc
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 44 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,65 @@
"aarch64-linux"
"aarch64-darwin"
];

in
flake-utils.lib.eachSystem supportedSystems (system:
let
overlays = [ haskellNix.overlay
(final: prev: {
haskellProject = (final: prev: {
hixProject =
final.haskell-nix.hix.project {
src = ./.;
evalSystem = "x86_64-linux";
};
})
});

checks = (final: prev: {
fourmolu = final.haskell-nix.tool
final.hixProject.args.compiler-nix-name
"fourmolu"
{ version = "latest"; };

hlintCheck = prev.runCommand "hlint-check" { buildInputs = [final.hlint]; } ''
cd "${final.hixProject.args.src}"
hlint app src test
if [[ "$?" -eq 0 ]]; then
touch $out
fi
'';

fourmoluCheck =
prev.runCommand
"fourmolu-check"
{
buildInputs = [ final.fourmolu ];
}
''
cd "${final.hixProject.args.src}"
fourmolu --mode check app src test
if [[ "$?" -eq 0 ]]; then
touch $out
fi
'';
});

overlays = [
haskellNix.overlay
haskellProject
checks
];

pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
flake = pkgs.hixProject.flake {};
in flake // {
checks = {
inherit (pkgs) hlintCheck fourmoluCheck;
};
legacyPackages = pkgs;
packages = flake.packages // {
default = flake.packages."seangine:exe:seangine";
inherit (pkgs) hlintCheck;
};
});

Expand Down
9 changes: 6 additions & 3 deletions nix/hix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
p.mingwW64
]);

shell.tools.cabal = "latest";
shell.tools.hlint = "latest";
shell.tools.haskell-language-server = "latest";
shell.tools = {
cabal = "latest";
fourmolu = "latest";
hlint = "latest";
haskell-language-server = "latest";
};
}

0 comments on commit 0d47b79

Please sign in to comment.