Skip to content

Commit

Permalink
removes pre-commit from nix check so CI only checks code
Browse files Browse the repository at this point in the history
hpack, fourmolu, hlint and nixfmt output depend on the exact versions
being used to have the same output. The pre-commit-check can fail if
even minor versions are different. This makes the check very brittle.
  • Loading branch information
Skyfold committed Dec 19, 2024
1 parent 110c758 commit abc9edd
Showing 1 changed file with 37 additions and 46 deletions.
83 changes: 37 additions & 46 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,18 @@
inherit system;
};

pkgsOverlayed = import inputs.nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
ghcPkgs =
(import inputs.nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
}).haskell.packages;

# Define GHC versions list
ghcVersions = [
"966"
"982"
];

# Create an attrset of GHC packages
ghcPkgs = builtins.listToAttrs (
map (version: {
name = "ghc${version}";
value = pkgsOverlayed.haskell.packages."ghc${version}";
}) ghcVersions
);

example-src = nix-filter.lib {
root = ./example;
include = [
Expand All @@ -116,8 +109,23 @@
];
};

pre-commit = git-hooks.lib.${system}.run {
src = src;
hooks = {
hlint.enable = true;
fourmolu.enable = true;
hpack.enable = true;
nixfmt-rfc-style.enable = true;
flake-checker = {
enable = true;
args = [ "--no-telemetry" ];
};
check-merge-conflicts.enable = true;
};
};

shellCommon = version: {
inherit (self.checks.${system}.pre-commit-check) shellHook;
inherit (pre-commit) shellHook;
buildInputs = with pkgs.haskell.packages."ghc${version}"; [
cabal-install
haskell-language-server
Expand All @@ -143,39 +151,22 @@
version: pkgs.haskell.lib.justStaticExecutables self.packages.${system}."ghc${version}-example";
in
{
checks =
{
pre-commit-check = git-hooks.lib.${system}.run {
src = src;
hooks = {
# hlint.enable = true;
# fourmolu.enable = true;
hpack.enable = true;
nixfmt-rfc-style.enable = true;
flake-checker = {
enable = true;
args = [ "--no-telemetry" ];
};
check-merge-conflicts.enable = true;
};
};
}
// (builtins.listToAttrs (
builtins.concatMap (version: [
{
name = "ghc${version}-check-${packageName}";
value = pkgs.runCommand "ghc${version}-check-${packageName}" {
buildInputs = [ self.packages.${system}."ghc${version}-${packageName}" ];
} "touch $out";
}
{
name = "ghc${version}-check-example";
value = pkgs.runCommand "ghc${version}-check-example" {
buildInputs = [ (examples-exe version) ];
} "type example; touch $out";
}
]) ghcVersions
));
checks = builtins.listToAttrs (
builtins.concatMap (version: [
{
name = "ghc${version}-check-${packageName}";
value = pkgs.runCommand "ghc${version}-check-${packageName}" {
buildInputs = [ self.packages.${system}."ghc${version}-${packageName}" ];
} "touch $out";
}
{
name = "ghc${version}-check-example";
value = pkgs.runCommand "ghc${version}-check-example" {
buildInputs = [ (examples-exe version) ];
} "type example; touch $out";
}
]) ghcVersions
);

apps =
{
Expand Down

0 comments on commit abc9edd

Please sign in to comment.