ormolu/default.nix
Utku Demir 2c5472944b Update ghc-lib-parser to 8.10.1
GHC 8.10.1 comes with some changes to the AST, which works great for
Ormolu, but causes this commit to be a bit large:

* Trees That Grow extension points for new constructors are now statically
  proven to be uninhabited, via noExtCon :: NoExtCon -> a. Thanks to this
  change I got rid of many notImplemented calls.
* LPat constructor is now a lot more usable, so we don't need to use
  the locatedPat combinator and can remove some boilerplate code.

Also it comes with ImportQualifiedPost and StandaloneKindSignatures
we should support. I did not implement them in this commit, they'll
be merged in later on.

It causes one behaviour change, where the ordering of qualified and
non-qualified imports of the same module is changed. This is due to
our usage of gcompare resulting a different ordering because of the
AST change caused by the ImportQualifiedPost extension. I think this is
acceptable and we shouldn't try to keep backwards compatibility there.

Another behaviour change is that previously HsExpr had a few extra
constructors for arrows and patterns used in expression context. Those
programs were syntactically incorrect, but refused on a later stage. But
we nonetheless formatted those constructs so Ormolu didn't fail there
while keeping the source code intact. However, now those constructors
are removed, so Ormolu fails with a parse error in this case (same as
GHC). I also removed some tests exhibiting this behaviour.
2020-04-05 10:53:40 +02:00

123 lines
2.9 KiB
Nix

{ pkgs ? (import ./nix/nixpkgs) }:
let
ormoluCompiler = "ghc865";
source = pkgs.lib.sourceByRegex ./. [
"^.*\.md$"
"^app.*$"
"^data.*$"
"^ormolu\.cabal$"
"^src.*$"
"^tests.*$"
];
haskellPackages = pkgs.haskell.packages.${ormoluCompiler}.override {
overrides = ormoluOverlay;
};
ormoluOverlay = self: super: {
"ormolu" = pkgs.haskell.lib.enableCabalFlag
(super.callCabal2nix "ormolu" source { }) "dev";
# Nixpkgs provides ghc-lib-parser-8.8.0.20190424, but we want
# ghc-lib-parser-8.10.1. We disable Haddock generation because it's way
# too slow.
"ghc-lib-parser" = pkgs.haskell.lib.dontHaddock
(super.callHackageDirect {
pkg = "ghc-lib-parser";
ver = "8.10.1.20200324";
sha256 = "0f2c68fzdj2lw6da2zpx7a0cx631im3kylwd85dzx1npsm1vzlbg";
} {});
};
ormolize = import ./nix/ormolize {
inherit pkgs;
inherit haskellPackages;
};
# NOTE We have to exclude some directories for some packages because
# Ormolu needs files to be parsable by Haddock which is not always the
# case. For example some tests and examples do not parse.
excludedHackageDirs = {
"aws" = ["Examples"];
"distributed-process" = ["benchmarks"];
"esqueleto" = ["test"];
"fay" = ["examples"];
"postgrest" = ["test"];
};
ormolizedPackages = doCheck:
pkgs.lib.mapAttrs (name: p: ormolize {
package = p;
inherit doCheck;
excludedDirs =
if builtins.hasAttr name excludedHackageDirs
then excludedHackageDirs.${name}
else [];
}) haskellPackages;
in {
ormolu = haskellPackages.ormolu;
ormoluShell = haskellPackages.shellFor {
packages = ps: [
ps.ormolu
];
buildInputs = [
haskellPackages.cabal-install
haskellPackages.ghcid
];
};
withOrmolu = haskellPackages.shellFor {
packages = ps: [];
buildInputs = [
haskellPackages.ormolu
];
};
inherit ormoluOverlay ormoluCompiler;
hackage = ormolizedPackages false;
hackageTests = with pkgs.lib; pkgs.recurseIntoAttrs (
let ps = [
"QuickCheck"
"ShellCheck"
"aeson"
"attoparsec"
"aws"
"capability"
"cassava"
"conduit"
"cryptonite"
"diagrams-core"
"distributed-process"
"esqueleto"
"fay"
"hakyll"
"haxl"
"hedgehog"
"hlint"
"megaparsec"
"ormolu"
"optics"
"postgrest"
"servant"
"servant-server"
"tensorflow"
"text_1_2_4_0"
"tls"
"yesod-core"
# Comment idempotence issue
# "Agda"
# "brick"
# "hledger"
# "http-client"
# "idris"
# "intero"
# "leksah"
# "pandoc"
# "pipes"
# "stack"
# Missing language extension
# "lens" #fixed in master
# "purescript"
];
in listToAttrs (map (p: nameValuePair p (ormolizedPackages true).${p}) ps)
);
}