2020-08-21 15:45:31 +03:00
|
|
|
{ pkgs ? (import ./nix/nixpkgs { inherit system; })
|
|
|
|
, system ? builtins.currentSystem
|
2020-08-22 23:48:38 +03:00
|
|
|
, ormoluCompiler ? "ghc884" # the shell doesn't work with ghc8101 yet
|
2020-04-14 16:14:08 +03:00
|
|
|
}:
|
2019-08-16 13:02:00 +03:00
|
|
|
|
2019-06-19 23:48:47 +03:00
|
|
|
let
|
2019-09-27 15:09:07 +03:00
|
|
|
source = pkgs.lib.sourceByRegex ./. [
|
2019-07-14 02:01:02 +03:00
|
|
|
"^.*\.md$"
|
|
|
|
"^app.*$"
|
|
|
|
"^data.*$"
|
2019-09-27 15:09:07 +03:00
|
|
|
"^ormolu\.cabal$"
|
2019-07-14 02:01:02 +03:00
|
|
|
"^src.*$"
|
|
|
|
"^tests.*$"
|
|
|
|
];
|
2019-08-16 13:02:00 +03:00
|
|
|
haskellPackages = pkgs.haskell.packages.${ormoluCompiler}.override {
|
|
|
|
overrides = ormoluOverlay;
|
2019-06-19 23:48:47 +03:00
|
|
|
};
|
2019-08-16 13:02:00 +03:00
|
|
|
ormoluOverlay = self: super: {
|
2020-04-14 16:14:08 +03:00
|
|
|
"ormolu" = super.callCabal2nixWithOptions "ormolu" source "-fdev" { };
|
2019-08-30 05:43:38 +03:00
|
|
|
};
|
2019-07-14 02:01:02 +03:00
|
|
|
ormolize = import ./nix/ormolize {
|
|
|
|
inherit pkgs;
|
|
|
|
inherit haskellPackages;
|
|
|
|
};
|
2020-04-14 21:30:40 +03:00
|
|
|
expectedFailures = [
|
|
|
|
"Agda"
|
|
|
|
"aws"
|
|
|
|
"distributed-process"
|
|
|
|
"esqueleto"
|
|
|
|
"fay"
|
2020-08-22 23:48:38 +03:00
|
|
|
"hlint"
|
2020-04-14 21:30:40 +03:00
|
|
|
"idris"
|
|
|
|
"intero"
|
|
|
|
"leksah"
|
|
|
|
"pandoc"
|
|
|
|
"pipes"
|
2020-08-22 23:48:38 +03:00
|
|
|
"postgrest"
|
2020-04-14 21:30:40 +03:00
|
|
|
"purescript"
|
2020-08-22 23:48:38 +03:00
|
|
|
"tensorflow"
|
|
|
|
] ++ (if ormoluCompiler == "ghc8101" then [] else ["lens"]);
|
2019-08-30 05:43:38 +03:00
|
|
|
ormolizedPackages = doCheck:
|
2019-09-17 14:16:47 +03:00
|
|
|
pkgs.lib.mapAttrs (name: p: ormolize {
|
|
|
|
package = p;
|
|
|
|
inherit doCheck;
|
2020-04-14 21:30:40 +03:00
|
|
|
expectedFailures =
|
|
|
|
if pkgs.lib.lists.any (x: x == name) expectedFailures
|
|
|
|
then ./expected-failures + "/${name}.txt"
|
|
|
|
else null;
|
2019-09-17 14:16:47 +03:00
|
|
|
}) haskellPackages;
|
2019-06-19 23:48:47 +03:00
|
|
|
in {
|
|
|
|
ormolu = haskellPackages.ormolu;
|
2020-04-25 00:30:08 +03:00
|
|
|
# We put the derivations in another attribute set to avoid building them
|
|
|
|
# when nix-build is run.
|
|
|
|
dev = {
|
|
|
|
ormoluShell =
|
|
|
|
haskellPackages.shellFor {
|
2020-04-14 16:14:08 +03:00
|
|
|
packages = ps: [
|
|
|
|
ps.ormolu
|
|
|
|
];
|
|
|
|
buildInputs = [
|
|
|
|
haskellPackages.cabal-install
|
|
|
|
haskellPackages.ghcid
|
|
|
|
];
|
|
|
|
};
|
2020-04-25 00:30:08 +03:00
|
|
|
withOrmolu = haskellPackages.shellFor {
|
|
|
|
packages = ps: [];
|
|
|
|
buildInputs = [
|
|
|
|
haskellPackages.cabal-install
|
|
|
|
haskellPackages.ormolu
|
|
|
|
];
|
|
|
|
};
|
2020-02-10 16:46:13 +03:00
|
|
|
};
|
2019-08-16 13:02:00 +03:00
|
|
|
inherit ormoluOverlay ormoluCompiler;
|
2019-08-30 05:43:38 +03:00
|
|
|
hackage = ormolizedPackages false;
|
|
|
|
hackageTests = with pkgs.lib; pkgs.recurseIntoAttrs (
|
|
|
|
let ps = [
|
2020-04-14 21:30:40 +03:00
|
|
|
"Agda"
|
2019-08-30 05:43:38 +03:00
|
|
|
"QuickCheck"
|
|
|
|
"ShellCheck"
|
|
|
|
"aeson"
|
|
|
|
"attoparsec"
|
2019-09-04 13:05:48 +03:00
|
|
|
"aws"
|
2020-04-14 21:30:40 +03:00
|
|
|
"brick"
|
2019-09-16 12:00:22 +03:00
|
|
|
"capability"
|
2019-08-30 05:43:38 +03:00
|
|
|
"cassava"
|
|
|
|
"conduit"
|
|
|
|
"cryptonite"
|
|
|
|
"diagrams-core"
|
|
|
|
"distributed-process"
|
2020-04-14 21:30:40 +03:00
|
|
|
"esqueleto"
|
2019-08-30 05:43:38 +03:00
|
|
|
"fay"
|
2019-09-17 14:16:47 +03:00
|
|
|
"hakyll"
|
2019-09-04 13:05:48 +03:00
|
|
|
"haxl"
|
2019-08-30 05:43:38 +03:00
|
|
|
"hedgehog"
|
2020-04-14 21:30:40 +03:00
|
|
|
"hledger"
|
2019-08-30 05:43:38 +03:00
|
|
|
"hlint"
|
2020-04-14 21:30:40 +03:00
|
|
|
"http-client"
|
|
|
|
"idris"
|
|
|
|
"intero"
|
|
|
|
"leksah"
|
|
|
|
"lens"
|
2019-08-30 05:43:38 +03:00
|
|
|
"megaparsec"
|
2019-10-27 15:58:13 +03:00
|
|
|
"optics"
|
2020-04-14 21:30:40 +03:00
|
|
|
"ormolu"
|
|
|
|
"pandoc"
|
2020-05-06 16:58:50 +03:00
|
|
|
"parsec3"
|
2020-04-14 21:30:40 +03:00
|
|
|
"pipes"
|
2019-08-30 05:43:38 +03:00
|
|
|
"postgrest"
|
2020-04-14 21:30:40 +03:00
|
|
|
"purescript"
|
2019-08-30 05:43:38 +03:00
|
|
|
"servant"
|
|
|
|
"servant-server"
|
2020-04-14 21:30:40 +03:00
|
|
|
"stack"
|
2019-08-30 05:43:38 +03:00
|
|
|
"tensorflow"
|
2019-09-04 09:33:58 +03:00
|
|
|
"text_1_2_4_0"
|
2019-09-06 20:22:15 +03:00
|
|
|
"tls"
|
2019-09-04 13:05:48 +03:00
|
|
|
"yesod-core"
|
2019-08-30 05:43:38 +03:00
|
|
|
];
|
|
|
|
in listToAttrs (map (p: nameValuePair p (ormolizedPackages true).${p}) ps)
|
|
|
|
);
|
2020-04-23 19:41:32 +03:00
|
|
|
regionTests = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "ormolu-region-tests";
|
|
|
|
src = ./region-tests;
|
|
|
|
buildInputs = [
|
|
|
|
haskellPackages.ormolu
|
|
|
|
pkgs.diffutils
|
|
|
|
];
|
|
|
|
doCheck = true;
|
|
|
|
buildPhase = ''
|
|
|
|
cp src.hs result-all-implicit.hs
|
2020-04-27 16:06:12 +03:00
|
|
|
ormolu --check-idempotence --mode inplace result-all-implicit.hs
|
2020-04-23 19:41:32 +03:00
|
|
|
cp src.hs result-all-explicit.hs
|
2020-06-16 12:40:26 +03:00
|
|
|
ormolu --check-idempotence --mode inplace --start-line 1 --end-line 18 result-all-explicit.hs
|
2020-04-23 19:41:32 +03:00
|
|
|
cp src.hs result-only-start.hs
|
2020-04-27 16:06:12 +03:00
|
|
|
ormolu --check-idempotence --mode inplace --start-line 1 result-only-start.hs
|
2020-04-23 19:41:32 +03:00
|
|
|
cp src.hs result-only-end.hs
|
2020-06-16 12:40:26 +03:00
|
|
|
ormolu --check-idempotence --mode inplace --end-line 18 result-only-end.hs
|
2020-04-24 20:43:45 +03:00
|
|
|
cp src.hs result-6-7.hs
|
2020-04-27 16:06:12 +03:00
|
|
|
ormolu --check-idempotence --mode inplace --start-line 6 --end-line 7 result-6-7.hs
|
2020-04-24 20:43:45 +03:00
|
|
|
cp src.hs result-6-8.hs
|
2020-04-27 16:06:12 +03:00
|
|
|
ormolu --check-idempotence --mode inplace --start-line 6 --end-line 8 result-6-8.hs
|
2020-06-16 12:40:26 +03:00
|
|
|
cp src.hs result-9-12.hs
|
|
|
|
ormolu --check-idempotence --mode inplace --start-line 9 --end-line 12 result-9-12.hs
|
|
|
|
cp src.hs result-17-18.hs
|
|
|
|
ormolu --check-idempotence --mode inplace --start-line 17 --end-line 18 result-17-18.hs
|
2020-04-23 19:41:32 +03:00
|
|
|
'';
|
|
|
|
checkPhase = ''
|
|
|
|
echo result-all-implicit.hs
|
|
|
|
diff --color=always expected-result-all.hs result-all-implicit.hs
|
|
|
|
echo result-all-explicit.hs
|
|
|
|
diff --color=always expected-result-all.hs result-all-explicit.hs
|
|
|
|
echo result-only-start.hs
|
|
|
|
diff --color=always expected-result-all.hs result-only-start.hs
|
|
|
|
echo result-only-end.hs
|
|
|
|
diff --color=always expected-result-all.hs result-only-end.hs
|
2020-04-24 20:43:45 +03:00
|
|
|
echo result-6-7.hs
|
|
|
|
diff --color=always expected-result-6-7.hs result-6-7.hs
|
|
|
|
echo result-6-8.hs
|
|
|
|
diff --color=always expected-result-6-8.hs result-6-8.hs
|
2020-06-16 12:40:26 +03:00
|
|
|
echo result-9-12.hs
|
|
|
|
diff --color=always expected-result-9-12.hs result-9-12.hs
|
|
|
|
echo result-17-18.hs
|
|
|
|
diff --color=always expected-result-17-18.hs result-17-18.hs
|
2020-04-23 19:41:32 +03:00
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir "$out"
|
|
|
|
find . -name '*.hs' -exec cp --parents {} $out \;
|
|
|
|
'';
|
|
|
|
};
|
2019-06-19 23:48:47 +03:00
|
|
|
}
|