From 8091da8f0f6efd365dddf4a09555ed49c093ea50 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 28 Jun 2020 21:27:02 -0400 Subject: feat(3p/haskellPackages): port in patches from xanthous Add a few relatively uncontroversial patches to fix some broken packages that I had developed for xanthous to the top-level third_party tree, so they can be reused by other people in the monorepo Change-Id: I68740477bda278c5dcc123080029ee4bd2cae37a Reviewed-on: https://cl.tvl.fyi/c/depot/+/740 Reviewed-by: Profpatsch Reviewed-by: tazjin --- third_party/default.nix | 5 +- third_party/haskell-overlay.nix | 49 +++++++ third_party/haskell_overlay/default.nix | 34 +++++ .../generic-arbitrary-export-garbitrary.patch | 12 ++ .../patches/hgeometry-fix-haddock.patch | 13 ++ .../patches/update-comonad-extras.patch | 154 +++++++++++++++++++++ users/glittershark/xanthous/default.nix | 2 +- users/glittershark/xanthous/haskell-overlay.nix | 49 ------- users/glittershark/xanthous/nixpkgs.nix | 12 +- users/glittershark/xanthous/shell.nix | 17 +-- 10 files changed, 279 insertions(+), 68 deletions(-) create mode 100644 third_party/haskell-overlay.nix create mode 100644 third_party/haskell_overlay/default.nix create mode 100644 third_party/haskell_overlay/patches/generic-arbitrary-export-garbitrary.patch create mode 100644 third_party/haskell_overlay/patches/hgeometry-fix-haddock.patch create mode 100644 third_party/haskell_overlay/patches/update-comonad-extras.patch delete mode 100644 users/glittershark/xanthous/haskell-overlay.nix diff --git a/third_party/default.nix b/third_party/default.nix index 02df1365c0..8f6bdc907b 100644 --- a/third_party/default.nix +++ b/third_party/default.nix @@ -77,7 +77,6 @@ let graphviz gzip haskell - haskellPackages iana-etc imagemagickBig installShellFiles @@ -172,6 +171,10 @@ let perl perlPackages utillinuxMinimal; + + haskellPackages = (nixpkgs.haskellPackages.override { + overrides = (import ./haskell_overlay { pkgs = nixpkgs; }); + }); }; in exposed.lib.fix(self: exposed // { diff --git a/third_party/haskell-overlay.nix b/third_party/haskell-overlay.nix new file mode 100644 index 0000000000..86a3514982 --- /dev/null +++ b/third_party/haskell-overlay.nix @@ -0,0 +1,49 @@ +{ pkgs ? import ./nixpkgs.nix {} }: +self: super: with pkgs.haskell.lib; rec { + generic-arbitrary = appendPatch + super.generic-arbitrary + [ ./build/generic-arbitrary-export-garbitrary.patch ]; + + hgeometry = + appendPatch + (self.callHackageDirect { + pkg = "hgeometry"; + ver = "0.9.0.0"; + sha256 = "02hyvbqm57lr47w90vdgl71cfbd6lvwpqdid9fcnmxkdjbq4kv6b"; + } {}) [ ./build/hgeometry-fix-haddock.patch ]; + + hgeometry-combinatorial = + self.callHackageDirect { + pkg = "hgeometry-combinatorial"; + ver = "0.9.0.0"; + sha256 = "12k41wd9fd1y3jd5djwcpwg2s1cva87wh14i0m1yn49zax9wl740"; + } {}; + + vinyl = overrideSrc (markUnbroken super.vinyl) + rec { + src = pkgs.fetchzip { + url = "mirror://hackage/vinyl-${version}/vinyl-${version}.tar.gz"; + sha256 = "190ffrmm76fh8fi9afkcda2vldf89y7dxj10434h28mbpq55kgsx"; + }; + version = "0.12.0"; + }; + + comonad-extras = appendPatch (markUnbroken super.comonad-extras) + [ ./build/update-comonad-extras.patch ]; + + ghc-prof-flamegraph = overrideCabal super.ghc-prof-flamegraph (oldAttrs: rec { + version = "0.2.0.0"; + + src = pkgs.fetchFromGitHub { + owner = "fpco"; + repo = "ghc-prof-flamegraph"; + rev = "8edd3b4806adeb25a4d55bed51c3afcc8e7a8e14"; + sha256 = "1i05pw495y5n24s1313iip8njn1lkf22a89izvi19iw7qkx062hr"; + fetchSubmodules = true; + }; + + libraryHaskellDepends = oldAttrs.libraryHaskellDepends ++ [ + self.optparse-applicative + ]; + }); +} diff --git a/third_party/haskell_overlay/default.nix b/third_party/haskell_overlay/default.nix new file mode 100644 index 0000000000..76e297173d --- /dev/null +++ b/third_party/haskell_overlay/default.nix @@ -0,0 +1,34 @@ +{ pkgs ? import ./nixpkgs.nix {} }: + +self: super: with pkgs.haskell.lib; rec { + generic-arbitrary = appendPatch + super.generic-arbitrary + [ ./patches/generic-arbitrary-export-garbitrary.patch ]; + + hgeometry = + appendPatch + (self.callHackageDirect { + pkg = "hgeometry"; + ver = "0.9.0.0"; + sha256 = "02hyvbqm57lr47w90vdgl71cfbd6lvwpqdid9fcnmxkdjbq4kv6b"; + } {}) [ ./patches/hgeometry-fix-haddock.patch ]; + + hgeometry-combinatorial = + self.callHackageDirect { + pkg = "hgeometry-combinatorial"; + ver = "0.9.0.0"; + sha256 = "12k41wd9fd1y3jd5djwcpwg2s1cva87wh14i0m1yn49zax9wl740"; + } {}; + + vinyl = overrideSrc (markUnbroken super.vinyl) + rec { + src = pkgs.fetchzip { + url = "mirror://hackage/vinyl-${version}/vinyl-${version}.tar.gz"; + sha256 = "190ffrmm76fh8fi9afkcda2vldf89y7dxj10434h28mbpq55kgsx"; + }; + version = "0.12.0"; + }; + + comonad-extras = appendPatch (markUnbroken super.comonad-extras) + [ ./patches/update-comonad-extras.patch ]; +} diff --git a/third_party/haskell_overlay/patches/generic-arbitrary-export-garbitrary.patch b/third_party/haskell_overlay/patches/generic-arbitrary-export-garbitrary.patch new file mode 100644 index 0000000000..f0c936bfca --- /dev/null +++ b/third_party/haskell_overlay/patches/generic-arbitrary-export-garbitrary.patch @@ -0,0 +1,12 @@ +diff --git a/src/Test/QuickCheck/Arbitrary/Generic.hs b/src/Test/QuickCheck/Arbitrary/Generic.hs +index fed6ab3..91f59f1 100644 +--- a/src/Test/QuickCheck/Arbitrary/Generic.hs ++++ b/src/Test/QuickCheck/Arbitrary/Generic.hs +@@ -23,6 +23,7 @@ The generated 'arbitrary' method is equivalent to + + module Test.QuickCheck.Arbitrary.Generic + ( Arbitrary(..) ++ , GArbitrary + , genericArbitrary + , genericShrink + ) where diff --git a/third_party/haskell_overlay/patches/hgeometry-fix-haddock.patch b/third_party/haskell_overlay/patches/hgeometry-fix-haddock.patch new file mode 100644 index 0000000000..748c65b3e0 --- /dev/null +++ b/third_party/haskell_overlay/patches/hgeometry-fix-haddock.patch @@ -0,0 +1,13 @@ +diff --git a/src/Data/Geometry/PlanarSubdivision/Merge.hs b/src/Data/Geometry/PlanarSubdivision/Merge.hs +index 1136114..3f4e7bb 100644 +--- a/src/Data/Geometry/PlanarSubdivision/Merge.hs ++++ b/src/Data/Geometry/PlanarSubdivision/Merge.hs +@@ -153,7 +153,7 @@ mergeWith' mergeFaces p1 p2 = PlanarSubdivision cs vd rd rf + -- we have to shift the number of the *Arcs*. Since every dart + -- consists of two arcs, we have to shift by numDarts / 2 + -- Furthermore, we take numFaces - 1 since we want the first +- -- *internal* face of p2 (the one with FaceId 1) to correspond with the first free ++ -- /internal/ face of p2 (the one with FaceId 1) to correspond with the first free + -- position (at index numFaces) + + cs = p1^.components <> p2'^.components diff --git a/third_party/haskell_overlay/patches/update-comonad-extras.patch b/third_party/haskell_overlay/patches/update-comonad-extras.patch new file mode 100644 index 0000000000..2a419f3202 --- /dev/null +++ b/third_party/haskell_overlay/patches/update-comonad-extras.patch @@ -0,0 +1,154 @@ +diff --git a/.travis.yml b/.travis.yml +index 1a9ac7a..81c69e9 100644 +--- a/.travis.yml ++++ b/.travis.yml +@@ -1,43 +1,4 @@ +-env: +- - GHCVER=7.0.1 CABALVER=1.16 +- - GHCVER=7.0.4 CABALVER=1.16 +- - GHCVER=7.2.2 CABALVER=1.16 +- - GHCVER=7.4.2 CABALVER=1.16 +- - GHCVER=7.6.3 CABALVER=1.16 +- - GHCVER=7.8.4 CABALVER=1.18 +- - GHCVER=7.10.1 CABALVER=1.22 +- - GHCVER=head CABALVER=1.22 +- +-matrix: +- allow_failures: +- - env: GHCVER=7.0.1 CABALVER=1.16 +- - env: GHCVER=7.0.4 CABALVER=1.16 +- - env: GHCVER=7.2.2 CABALVER=1.16 +- - env: GHCVER=head CABALVER=1.22 +- +-before_install: +- - travis_retry sudo add-apt-repository -y ppa:hvr/ghc +- - travis_retry sudo apt-get update +- - travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER +- - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH +- - cabal --version +- +-install: +- - travis_retry cabal update +- - cabal install --enable-tests --only-dependencies +- +-script: +- - cabal configure -v2 --enable-tests +- - cabal build +- - cabal sdist +- - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ; +- cd dist/; +- if [ -f "$SRC_TGZ" ]; then +- cabal install "$SRC_TGZ"; +- else +- echo "expected '$SRC_TGZ' not found"; +- exit 1; +- fi ++language: haskell + + notifications: + irc: +diff --git a/comonad-extras.cabal b/comonad-extras.cabal +index 2e449c1..77a2f0d 100644 +--- a/comonad-extras.cabal ++++ b/comonad-extras.cabal +@@ -1,6 +1,6 @@ +-name: comonad-extras + category: Control, Comonads +-version: 4.0.1 ++name: comonad-extras ++version: 5.0 + license: BSD3 + cabal-version: >= 1.6 + license-file: LICENSE +@@ -34,11 +34,11 @@ library + build-depends: + array >= 0.3 && < 0.6, + base >= 4 && < 5, +- containers >= 0.4 && < 0.7, +- comonad >= 4 && < 6, ++ containers >= 0.6 && < 0.7, ++ comonad >= 5 && < 6, + distributive >= 0.3.2 && < 1, +- semigroupoids >= 4 && < 6, +- transformers >= 0.2 && < 0.6 ++ semigroupoids >= 5 && < 6, ++ transformers >= 0.5 && < 0.6 + + exposed-modules: + Control.Comonad.Store.Zipper +diff --git a/src/Control/Comonad/Store/Pointer.hs b/src/Control/Comonad/Store/Pointer.hs +index 5e41f4e..d99b50f 100644 +--- a/src/Control/Comonad/Store/Pointer.hs ++++ b/src/Control/Comonad/Store/Pointer.hs +@@ -44,9 +44,6 @@ module Control.Comonad.Store.Pointer + , module Control.Comonad.Store.Class + ) where + +-#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ < 710 +-import Control.Applicative +-#endif + import Control.Comonad + import Control.Comonad.Hoist.Class + import Control.Comonad.Trans.Class +@@ -56,32 +53,10 @@ import Control.Comonad.Env.Class + import Data.Functor.Identity + import Data.Functor.Extend + import Data.Array +- +-#if __GLASGOW_HASKELL__ ++#ifdef __GLASGOW_HASKELL__ + import Data.Typeable + #endif + +-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 708 +-instance (Typeable i, Typeable1 w) => Typeable1 (PointerT i w) where +- typeOf1 diwa = mkTyConApp storeTTyCon [typeOf (i diwa), typeOf1 (w diwa)] +- where +- i :: PointerT i w a -> i +- i = undefined +- w :: PointerT i w a -> w a +- w = undefined +- +-instance (Typeable i, Typeable1 w, Typeable a) => Typeable (PointerT i w a) where +- typeOf = typeOfDefault +- +-storeTTyCon :: TyCon +-#if __GLASGOW_HASKELL__ < 704 +-storeTTyCon = mkTyCon "Control.Comonad.Trans.Store.Pointer.PointerT" +-#else +-storeTTyCon = mkTyCon3 "comonad-extras" "Control.Comonad.Trans.Store.Pointer" "PointerT" +-#endif +-{-# NOINLINE storeTTyCon #-} +-#endif +- + type Pointer i = PointerT i Identity + + pointer :: Array i a -> i -> Pointer i a +@@ -91,7 +66,7 @@ runPointer :: Pointer i a -> (Array i a, i) + runPointer (PointerT (Identity f) i) = (f, i) + + data PointerT i w a = PointerT (w (Array i a)) i +-#if __GLASGOW_HASKELL__ >= 708 ++#ifdef __GLASGOW_HASKELL__ + deriving Typeable + #endif + +@@ -133,4 +108,3 @@ instance (ComonadTraced m w, Ix i) => ComonadTraced m (PointerT i w) where + + instance (ComonadEnv m w, Ix i) => ComonadEnv m (PointerT i w) where + ask = ask . lower +- +diff --git a/src/Control/Comonad/Store/Zipper.hs b/src/Control/Comonad/Store/Zipper.hs +index 6dab6fd..decc378 100644 +--- a/src/Control/Comonad/Store/Zipper.hs ++++ b/src/Control/Comonad/Store/Zipper.hs +@@ -15,9 +15,6 @@ + module Control.Comonad.Store.Zipper + ( Zipper, zipper, zipper1, unzipper, size) where + +-#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ < 710 +-import Control.Applicative +-#endif + import Control.Comonad (Comonad(..)) + import Data.Functor.Extend + import Data.Foldable diff --git a/users/glittershark/xanthous/default.nix b/users/glittershark/xanthous/default.nix index 4af535a34d..c4260fe258 100644 --- a/users/glittershark/xanthous/default.nix +++ b/users/glittershark/xanthous/default.nix @@ -16,6 +16,6 @@ let xanthous = (if failOnWarnings then pkgs.haskell.lib.failOnAllWarnings else id) ((pkgs.haskellPackages - .extend (import ./haskell-overlay.nix { inherit pkgs; }) + # .extend (import ./haskell-overlay.nix { inherit pkgs; }) ).callPackage (import ./pkg.nix { inherit pkgs; }) {}); in xanthous // { inherit hie; } diff --git a/users/glittershark/xanthous/haskell-overlay.nix b/users/glittershark/xanthous/haskell-overlay.nix deleted file mode 100644 index 86a3514982..0000000000 --- a/users/glittershark/xanthous/haskell-overlay.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ pkgs ? import ./nixpkgs.nix {} }: -self: super: with pkgs.haskell.lib; rec { - generic-arbitrary = appendPatch - super.generic-arbitrary - [ ./build/generic-arbitrary-export-garbitrary.patch ]; - - hgeometry = - appendPatch - (self.callHackageDirect { - pkg = "hgeometry"; - ver = "0.9.0.0"; - sha256 = "02hyvbqm57lr47w90vdgl71cfbd6lvwpqdid9fcnmxkdjbq4kv6b"; - } {}) [ ./build/hgeometry-fix-haddock.patch ]; - - hgeometry-combinatorial = - self.callHackageDirect { - pkg = "hgeometry-combinatorial"; - ver = "0.9.0.0"; - sha256 = "12k41wd9fd1y3jd5djwcpwg2s1cva87wh14i0m1yn49zax9wl740"; - } {}; - - vinyl = overrideSrc (markUnbroken super.vinyl) - rec { - src = pkgs.fetchzip { - url = "mirror://hackage/vinyl-${version}/vinyl-${version}.tar.gz"; - sha256 = "190ffrmm76fh8fi9afkcda2vldf89y7dxj10434h28mbpq55kgsx"; - }; - version = "0.12.0"; - }; - - comonad-extras = appendPatch (markUnbroken super.comonad-extras) - [ ./build/update-comonad-extras.patch ]; - - ghc-prof-flamegraph = overrideCabal super.ghc-prof-flamegraph (oldAttrs: rec { - version = "0.2.0.0"; - - src = pkgs.fetchFromGitHub { - owner = "fpco"; - repo = "ghc-prof-flamegraph"; - rev = "8edd3b4806adeb25a4d55bed51c3afcc8e7a8e14"; - sha256 = "1i05pw495y5n24s1313iip8njn1lkf22a89izvi19iw7qkx062hr"; - fetchSubmodules = true; - }; - - libraryHaskellDepends = oldAttrs.libraryHaskellDepends ++ [ - self.optparse-applicative - ]; - }); -} diff --git a/users/glittershark/xanthous/nixpkgs.nix b/users/glittershark/xanthous/nixpkgs.nix index 19bf2c59ce..7d7c164405 100644 --- a/users/glittershark/xanthous/nixpkgs.nix +++ b/users/glittershark/xanthous/nixpkgs.nix @@ -1,9 +1,3 @@ -let - inherit (import {}) fetchFromGitHub; - nixpkgs = fetchFromGitHub { - owner = "NixOS"; - repo = "nixpkgs-channels"; - rev = "54f385241e6649128ba963c10314942d73245479"; - sha256 = "0bd4v8v4xcdbaiaa59yqprnc6dkb9jv12mb0h5xz7b51687ygh9l"; - }; -in import nixpkgs +args: +let pkgs = (import ../../../. args).third_party; +in pkgs // { inherit pkgs; } diff --git a/users/glittershark/xanthous/shell.nix b/users/glittershark/xanthous/shell.nix index e062bf9ce1..b78844c0ee 100644 --- a/users/glittershark/xanthous/shell.nix +++ b/users/glittershark/xanthous/shell.nix @@ -1,16 +1,16 @@ -{ nixpkgs ? import ./nixpkgs.nix {}, compiler ? "ghc865", withHoogle ? true }: +{ nixpkgs ? import ./nixpkgs.nix {} +, pkgs ? nixpkgs.pkgs +, compiler ? "ghc865" +, withHoogle ? true +}: let - inherit (nixpkgs) pkgs; - - pkg = import ./pkg.nix { inherit nixpkgs; }; + pkg = import ./pkg.nix { inherit pkgs; }; packageSet = ( if compiler == "default" then pkgs.haskellPackages else pkgs.haskell.packages.${compiler} - ).override { - overrides = import ./haskell-overlay.nix { inherit nixpkgs; }; - }; + ); haskellPackages = ( if withHoogle @@ -18,7 +18,8 @@ let overrides = (self: super: { ghc = super.ghc // { withPackages = super.ghc.withHoogle; }; ghcWithPackages = self.ghc.withPackages; - } // (import ./haskell-overlay.nix { inherit nixpkgs; }) self super); + } // (import ../../../third_party/haskell_overlay { inherit pkgs; }) + self super); } else packageSet ); -- cgit 1.4.1