@@ -1,14 +1,19 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
3module Distribution.Nixpkgs.Haskell.FromCabal.PostProcess ( postProcess, pkg ) where
4module Distribution.Nixpkgs.Haskell.FromCabal.PostProcess ( postProcess, pkg ) where
5import Control.Lens
6import Control.Lens
7+import Control.Monad.Trans.State
6import Data.List.Split
8import Data.List.Split
9+import Data.Map ( Map )
10+import qualified Data.Map as Map
7import Data.Set ( Set )
12import Data.Set ( Set )
8import qualified Data.Set as Set
13import qualified Data.Set as Set
10import Distribution.Nixpkgs.Haskell
14import Distribution.Nixpkgs.Haskell
11import Distribution.Nixpkgs.Meta
15import Distribution.Nixpkgs.Meta
16+import Distribution.Nixpkgs.License
12import Distribution.Package
17import Distribution.Package
13import Distribution.System
18import Distribution.System
14import Distribution.Text
19import Distribution.Text
@@ -16,7 +21,11 @@ import Distribution.Version
16import Language.Nix
21import Language.Nix
18postProcess :: Derivation -> Derivation
23postProcess :: Derivation -> Derivation
19−postProcess deriv = foldr ($) (fixGtkBuilds deriv) [ f | (Dependency n vr, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
25+ foldr (.) id [ f | (Dependency n vr _, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
27+ . fixBuildDependsForTools
21fixGtkBuilds :: Derivation -> Derivation
30fixGtkBuilds :: Derivation -> Derivation
22fixGtkBuilds drv = drv & dependencies . pkgconfig %~ Set.filter (not . collidesWithHaskellName)
31fixGtkBuilds drv = drv & dependencies . pkgconfig %~ Set.filter (not . collidesWithHaskellName)
@@ -24,41 +33,79 @@ fixGtkBuilds drv = drv & dependencies . pkgconfig %~ Set.filter (not . collidesW
24 & dependencies . tool %~ Set.filter (not . collidesWithHaskellName)
33 & dependencies . tool %~ Set.filter (not . collidesWithHaskellName)
26 collidesWithHaskellName :: Binding -> Bool
35 collidesWithHaskellName :: Binding -> Bool
27− collidesWithHaskellName b = view localName b `Set.member` buildDeps
36+ collidesWithHaskellName b = case buildDeps Map.!? view localName b of
37+ Nothing -> False -- totally uncollided
38+ Just p -> p /= view reference b -- identical is not collision, and important to preserve for cross
29 myName :: Identifier
40 myName :: Identifier
30 myName = ident # unPackageName (packageName drv)
41 myName = ident # unPackageName (packageName drv)
32− buildDeps :: Set Identifier
43+ buildDeps :: Map Identifier Path
33− buildDeps = Set.delete myName (setOf (dependencies . haskell . folded . localName) drv)
44+ buildDeps = Map.delete myName (toMapOf (dependencies . haskell . to Set.toList . traverse . binding . ifolded) drv)
46+-- Per https://github.com/haskell/cabal/issues/5412 hvr considers
47+-- `build-depends` providing executables an accident, and fragile one at that,
48+-- unworthy of any compatibility hacks. But while he and the other Hackage
49+-- maintainers is dedicated to fixing executables and libraries on Hackage, test
50+-- suites and benchmarks are not a priority, as it is trivial to skip building
51+-- test-suites with cabal-install. Nix however wishes to build test suites much
52+-- more widely, so skipping those components is not an option.
54+-- Between that, and Stack not changing behavior as of
55+-- https://github.com/commercialhaskell/stack/pull/4132, it seems likely that
56+-- for a while packages scraped from Hackage will continue to improperly use
57+-- `build-depends: package-for-tool` instead of `build-tool-depends` (which does
58+-- also work for Stack). Until that changes, we provide do this to work around
59+-- those package's brokenness.
60+fixBuildDependsForTools :: Derivation -> Derivation
61+fixBuildDependsForTools = foldr (.) id
62+ [ fmap snd $ runState $ do
63+ needs <- use $ cloneLens c . haskell . contains p
64+ cloneLens c . tool . contains p ||= needs
65+ | (c :: ALens' Derivation BuildInfo) <- [ testDepends, benchmarkDepends ]
66+ , p <- self <$> [ "hspec-discover"
35hooks :: [(Dependency, Derivation -> Derivation)]
73hooks :: [(Dependency, Derivation -> Derivation)]
37 [ ("Agda < 2.5", set (executableDepends . tool . contains (pkg "emacs")) True . set phaseOverrides agdaPostInstall)
75 [ ("Agda < 2.5", set (executableDepends . tool . contains (pkg "emacs")) True . set phaseOverrides agdaPostInstall)
38 , ("Agda >= 2.5", set (executableDepends . tool . contains (pkg "emacs")) True . set phaseOverrides agda25PostInstall)
76 , ("Agda >= 2.5", set (executableDepends . tool . contains (pkg "emacs")) True . set phaseOverrides agda25PostInstall)
39 , ("alex < 3.1.5", set (testDepends . tool . contains (pkg "perl")) True)
77 , ("alex < 3.1.5", set (testDepends . tool . contains (pkg "perl")) True)
40− , ("alex", set (executableDepends . tool . contains (bind "self.happy")) True)
78+ , ("alex", set (executableDepends . tool . contains (self "happy")) True)
41− , ("alsa-core", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux))) , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
79+ , ("alsa-core", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
42 , ("bindings-GLFW", over (libraryDepends . system) (Set.union (Set.fromList [bind "pkgs.xorg.libXext", bind "pkgs.xorg.libXfixes"])))
80 , ("bindings-GLFW", over (libraryDepends . system) (Set.union (Set.fromList [bind "pkgs.xorg.libXext", bind "pkgs.xorg.libXfixes"])))
43− , ("bindings-lxc", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux))) , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
81+ , ("bindings-lxc", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
44− , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
82+ , ("bustle", bustleOverrides)
45 , ("Cabal", set doCheck False) -- test suite doesn't work in Nix
83 , ("Cabal", set doCheck False) -- test suite doesn't work in Nix
84+ , ("Cabal >2.2", over (setupDepends . haskell) (Set.union (Set.fromList [self "mtl", self "parsec"]))) -- https://github.com/haskell/cabal/issues/5391
46 , ("cabal-helper", set doCheck False) -- https://github.com/DanielG/cabal-helper/issues/17
85 , ("cabal-helper", set doCheck False) -- https://github.com/DanielG/cabal-helper/issues/17
47 , ("cabal-install", set doCheck False . set phaseOverrides cabalInstallPostInstall)
86 , ("cabal-install", set doCheck False . set phaseOverrides cabalInstallPostInstall)
87+ , ("cabal2nix > 2", cabal2nixOverrides)
48 , ("darcs", set phaseOverrides darcsInstallPostInstall . set doCheck False)
88 , ("darcs", set phaseOverrides darcsInstallPostInstall . set doCheck False)
49 , ("dbus", set doCheck False) -- don't execute tests that try to access the network
89 , ("dbus", set doCheck False) -- don't execute tests that try to access the network
50 , ("dns", set testTarget "spec") -- don't execute tests that try to access the network
90 , ("dns", set testTarget "spec") -- don't execute tests that try to access the network
51 , ("eventstore", over (metaSection . platforms) (Set.filter (\(Platform arch _) -> arch == X86_64)))
91 , ("eventstore", over (metaSection . platforms) (Set.filter (\(Platform arch _) -> arch == X86_64)))
52 , ("freenect < 1.2.1", over configureFlags (Set.union (Set.fromList ["--extra-include-dirs=${pkgs.freenect}/include/libfreenect", "--extra-lib-dirs=${pkgs.freenect}/lib"])))
92 , ("freenect < 1.2.1", over configureFlags (Set.union (Set.fromList ["--extra-include-dirs=${pkgs.freenect}/include/libfreenect", "--extra-lib-dirs=${pkgs.freenect}/lib"])))
93+ , ("fltkhs", set (libraryDepends . system . contains (pkg "fltk14")) True . over (libraryDepends . pkgconfig) (Set.union (pkgs ["libGLU", "libGL"]))) -- TODO: fltk14 belongs into the *setup* dependencies.
53 , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)
94 , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)
54 , ("gi-cairo", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
95 , ("gi-cairo", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
96+ , ("gi-gdk", set runHaddock True )
97+ , ("gi-gio", set runHaddock True )
98+ , ("gi-glib", set runHaddock True )
55 , ("gi-gst", giGstLibOverrides "gstreamer") -- https://github.com/haskell-gi/haskell-gi/issues/36
99 , ("gi-gst", giGstLibOverrides "gstreamer") -- https://github.com/haskell-gi/haskell-gi/issues/36
56 , ("gi-gstaudio", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
100 , ("gi-gstaudio", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
57 , ("gi-gstbase", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
101 , ("gi-gstbase", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
58 , ("gi-gstvideo", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
102 , ("gi-gstvideo", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
103+ , ("gi-gtk", set runHaddock True )
59 , ("gi-javascriptcore < 4.0.0.0", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
104 , ("gi-javascriptcore < 4.0.0.0", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
60 , ("gi-pango", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
105 , ("gi-pango", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
106+ , ("gi-pango", set runHaddock True )
61 , ("gi-pangocairo", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
107 , ("gi-pangocairo", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
108+ , ("gi-vte", set runHaddock True )
62 , ("gi-webkit", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
109 , ("gi-webkit", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
63 , ("gio", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
110 , ("gio", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
64 , ("git", set doCheck False) -- https://github.com/vincenthz/hit/issues/33
111 , ("git", set doCheck False) -- https://github.com/vincenthz/hit/issues/33
@@ -67,7 +114,9 @@ hooks =
67 , ("github-backup", set (executableDepends . tool . contains (pkg "git")) True)
114 , ("github-backup", set (executableDepends . tool . contains (pkg "git")) True)
68 , ("GLFW", over (libraryDepends . system) (Set.union (Set.fromList [bind "pkgs.xorg.libXext", bind "pkgs.xorg.libXfixes"])))
115 , ("GLFW", over (libraryDepends . system) (Set.union (Set.fromList [bind "pkgs.xorg.libXext", bind "pkgs.xorg.libXfixes"])))
69 , ("GlomeVec", set (libraryDepends . pkgconfig . contains (bind "self.llvmPackages.llvm")) True)
116 , ("GlomeVec", set (libraryDepends . pkgconfig . contains (bind "self.llvmPackages.llvm")) True)
117+ , ("graphviz", set (testDepends . system . contains (pkg "graphviz")) True)
70 , ("gtk3", gtk3Hook)
118 , ("gtk3", gtk3Hook)
119+ , ("gtkglext", gtkglextHook)
71 , ("haddock", haddockHook) -- https://github.com/haskell/haddock/issues/511
120 , ("haddock", haddockHook) -- https://github.com/haskell/haddock/issues/511
72 , ("hakyll", set (testDepends . tool . contains (pkg "utillinux")) True) -- test suite depends on "rev"
121 , ("hakyll", set (testDepends . tool . contains (pkg "utillinux")) True) -- test suite depends on "rev"
73 , ("haskell-src-exts", set doCheck False)
122 , ("haskell-src-exts", set doCheck False)
@@ -78,31 +127,34 @@ hooks =
78 , ("holy-project", set doCheck False) -- attempts to access the network
127 , ("holy-project", set doCheck False) -- attempts to access the network
79 , ("hoogle", set testTarget "--test-option=--no-net")
128 , ("hoogle", set testTarget "--test-option=--no-net")
80 , ("hsignal < 0.2.7.4", set phaseOverrides "prePatch = \"rm -v Setup.lhs\";") -- https://github.com/amcphail/hsignal/issues/1
129 , ("hsignal < 0.2.7.4", set phaseOverrides "prePatch = \"rm -v Setup.lhs\";") -- https://github.com/amcphail/hsignal/issues/1
81− , ("hslua < 0.9.3", over (libraryDepends . each) (replace (pkg "lua") (pkg "lua5_1")))
130+ , ("hslua < 0.9.3", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_1")))
82− , ("hslua >= 0.9.3", over (libraryDepends . each) (replace (pkg "lua") (pkg "lua5_3")))
131+ , ("hslua >= 0.9.3", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_3")))
83 , ("hspec-core >= 2.4.4", hspecCoreOverrides)
132 , ("hspec-core >= 2.4.4", hspecCoreOverrides)
84 , ("http-client", set doCheck False) -- attempts to access the network
133 , ("http-client", set doCheck False) -- attempts to access the network
85 , ("http-client-openssl >= 0.2.0.1", set doCheck False) -- attempts to access the network
134 , ("http-client-openssl >= 0.2.0.1", set doCheck False) -- attempts to access the network
86 , ("http-client-tls >= 0.2.2", set doCheck False) -- attempts to access the network
135 , ("http-client-tls >= 0.2.2", set doCheck False) -- attempts to access the network
87 , ("http-conduit", set doCheck False) -- attempts to access the network
136 , ("http-conduit", set doCheck False) -- attempts to access the network
88 , ("imagemagick", set (libraryDepends . pkgconfig . contains (pkg "imagemagick")) True) -- https://github.com/NixOS/cabal2nix/issues/136
137 , ("imagemagick", set (libraryDepends . pkgconfig . contains (pkg "imagemagick")) True) -- https://github.com/NixOS/cabal2nix/issues/136
89− , ("include-file <= 0.1.0.2", set (libraryDepends . haskell . contains (bind "self.random")) True) -- https://github.com/Daniel-Diaz/include-file/issues/1
138+ , ("include-file <= 0.1.0.2", set (libraryDepends . haskell . contains (self "random")) True) -- https://github.com/Daniel-Diaz/include-file/issues/1
90 , ("js-jquery", set doCheck False) -- attempts to access the network
139 , ("js-jquery", set doCheck False) -- attempts to access the network
91 , ("libconfig", over (libraryDepends . system) (replace "config = null" (pkg "libconfig")))
140 , ("libconfig", over (libraryDepends . system) (replace "config = null" (pkg "libconfig")))
92 , ("libxml", set (configureFlags . contains "--extra-include-dir=${libxml2.dev}/include/libxml2") True)
141 , ("libxml", set (configureFlags . contains "--extra-include-dir=${libxml2.dev}/include/libxml2") True)
93 , ("liquid-fixpoint", set (executableDepends . system . contains (pkg "ocaml")) True . set (testDepends . system . contains (pkg "z3")) True . set (testDepends . system . contains (pkg "nettools")) True . set (testDepends . system . contains (pkg "git")) True . set doCheck False)
142 , ("liquid-fixpoint", set (executableDepends . system . contains (pkg "ocaml")) True . set (testDepends . system . contains (pkg "z3")) True . set (testDepends . system . contains (pkg "nettools")) True . set (testDepends . system . contains (pkg "git")) True . set doCheck False)
94 , ("liquidhaskell", set (testDepends . system . contains (pkg "z3")) True)
143 , ("liquidhaskell", set (testDepends . system . contains (pkg "z3")) True)
95− , ("lzma-clib", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)) . set (libraryDepends . haskell . contains (bind "self.only-buildable-on-windows")) False)
144+ , ("lzma-clib", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)) . set (libraryDepends . haskell . contains (self "only-buildable-on-windows")) False)
96− , ("MFlow < 4.6", set (libraryDepends . tool . contains (bind "self.cpphs")) True)
145+ , ("MFlow < 4.6", set (libraryDepends . tool . contains (self "cpphs")) True)
97 , ("mwc-random", set doCheck False)
146 , ("mwc-random", set doCheck False)
98 , ("mysql", set (libraryDepends . system . contains (pkg "mysql")) True)
147 , ("mysql", set (libraryDepends . system . contains (pkg "mysql")) True)
99 , ("network-attoparsec", set doCheck False) -- test suite requires network access
148 , ("network-attoparsec", set doCheck False) -- test suite requires network access
100 , ("numeric-qq", set doCheck False) -- test suite doesn't finish even after 1+ days
149 , ("numeric-qq", set doCheck False) -- test suite doesn't finish even after 1+ days
101 , ("opencv", opencvOverrides)
150 , ("opencv", opencvOverrides)
102− , ("pandoc >= 1.16.0.2", set doCheck False) -- https://github.com/jgm/pandoc/issues/2709 and https://github.com/fpco/stackage/issues/1332
151+ , ("pandoc >= 1.16.0.2 && < 2.5", set doCheck False) -- https://github.com/jgm/pandoc/issues/2709 and https://github.com/fpco/stackage/issues/1332
103− , ("pandoc", set jailbreak False) -- jailbreak-cabal break the build
152+ , ("pandoc < 2.6", pandocPre26Overrides)
153+ , ("pandoc >= 2.6", pandocOverrides)
104− , ("pandoc-citeproc", set doCheck False) -- https://github.com/jgm/pandoc-citeproc/issues/172
154+ , ("pandoc-citeproc", set doCheck False) -- https://github.com/jgm/pandoc-citeproc/issues/369
105 , ("purescript", set doCheck False) -- test suite doesn't cope with Nix build env
155 , ("purescript", set doCheck False) -- test suite doesn't cope with Nix build env
156+ , ("proto-lens-protobuf-types", set (libraryDepends . tool . contains (pkg "protobuf")) True)
157+ , ("proto-lens-protoc", set (libraryDepends . tool . contains (pkg "protobuf")) True)
106 , ("qtah-cpp-qt5", set (libraryDepends . system . contains (bind "pkgs.qt5.qtbase")) True)
158 , ("qtah-cpp-qt5", set (libraryDepends . system . contains (bind "pkgs.qt5.qtbase")) True)
107 , ("qtah-qt5", set (libraryDepends . tool . contains (bind "pkgs.qt5.qtbase")) True)
159 , ("qtah-qt5", set (libraryDepends . tool . contains (bind "pkgs.qt5.qtbase")) True)
108 , ("readline", over (libraryDepends . system) (Set.union (pkgs ["readline", "ncurses"])))
160 , ("readline", over (libraryDepends . system) (Set.union (pkgs ["readline", "ncurses"])))
@@ -116,10 +168,11 @@ hooks =
116 , ("target", set (testDepends . system . contains (pkg "z3")) True)
168 , ("target", set (testDepends . system . contains (pkg "z3")) True)
117 , ("terminfo", set (libraryDepends . system . contains (pkg "ncurses")) True)
169 , ("terminfo", set (libraryDepends . system . contains (pkg "ncurses")) True)
118 , ("text", set doCheck False) -- break infinite recursion
170 , ("text", set doCheck False) -- break infinite recursion
171+ , ("tensorflow-proto", set (libraryDepends . tool . contains (pkg "protobuf")) True)
119− , ("thyme", set (libraryDepends . tool . contains (bind "self.cpphs")) True) -- required on Darwin
172+ , ("thyme", set (libraryDepends . tool . contains (self "cpphs")) True) -- required on Darwin
120 , ("twilio", set doCheck False) -- attempts to access the network
173 , ("twilio", set doCheck False) -- attempts to access the network
121 , ("tz", set phaseOverrides "preConfigure = \"export TZDIR=${pkgs.tzdata}/share/zoneinfo\";")
174 , ("tz", set phaseOverrides "preConfigure = \"export TZDIR=${pkgs.tzdata}/share/zoneinfo\";")
122− , ("udev", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux))) , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
175+ , ("udev", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
123 , ("webkitgtk3", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
176 , ("webkitgtk3", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
124 , ("webkitgtk3-javascriptcore", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
177 , ("webkitgtk3-javascriptcore", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
125 , ("websockets", set doCheck False) -- https://github.com/jaspervdj/websockets/issues/104
178 , ("websockets", set doCheck False) -- https://github.com/jaspervdj/websockets/issues/104
@@ -128,14 +181,18 @@ hooks =
128 , ("wxc", wxcHook)
181 , ("wxc", wxcHook)
129 , ("wxcore", set (libraryDepends . pkgconfig . contains (pkg "wxGTK")) True)
182 , ("wxcore", set (libraryDepends . pkgconfig . contains (pkg "wxGTK")) True)
130 , ("X11", over (libraryDepends . system) (Set.union (Set.fromList $ map bind ["pkgs.xorg.libXinerama","pkgs.xorg.libXext","pkgs.xorg.libXrender","pkgs.xorg.libXScrnSaver"])))
183 , ("X11", over (libraryDepends . system) (Set.union (Set.fromList $ map bind ["pkgs.xorg.libXinerama","pkgs.xorg.libXext","pkgs.xorg.libXrender","pkgs.xorg.libXScrnSaver"])))
131− , ("xmonad", set phaseOverrides xmonadPostInstall)
184+ , ("xmonad >= 0.14.2", set phaseOverrides xmonadPostInstall)
132− , ("zip-archive < 0.3.1", over (testDepends . tool) (replace (bind "self.zip") (pkg "zip")))
185+ , ("zip-archive < 0.3.1", over (testDepends . tool) (replace (self "zip") (pkg "zip")))
133 , ("zip-archive >= 0.3.1 && < 0.3.2.3", over (testDepends . tool) (Set.union (Set.fromList [pkg "zip", pkg "unzip"]))) -- https://github.com/jgm/zip-archive/issues/35
186 , ("zip-archive >= 0.3.1 && < 0.3.2.3", over (testDepends . tool) (Set.union (Set.fromList [pkg "zip", pkg "unzip"]))) -- https://github.com/jgm/zip-archive/issues/35
187+ , ("zip-archive >= 0.4", set (testDepends . tool . contains (pkg "which")) True)
136pkg :: Identifier -> Binding
190pkg :: Identifier -> Binding
137pkg i = binding # (i, path # ["pkgs",i])
191pkg i = binding # (i, path # ["pkgs",i])
193+self :: Identifier -> Binding
194+self i = binding # (i, path # ["self",i])
139pkgs :: [Identifier] -> Set Binding
196pkgs :: [Identifier] -> Set Binding
140pkgs = Set.fromList . map pkg
197pkgs = Set.fromList . map pkg
@@ -145,10 +202,18 @@ bind s = binding # (i, path # is)
145 is = map (review ident) (splitOn "." s)
202 is = map (review ident) (splitOn "." s)
146 i = last is
203 i = last is
205+-- | @replace old new bset@ replaces the Nix binding @old@ with @new@ in the
206+-- set of bindings @bset@. If @old@ is not found in @bset@, then the function
207+-- fails with an 'error'.
148replace :: Binding -> Binding -> Set Binding -> Set Binding
208replace :: Binding -> Binding -> Set Binding -> Set Binding
149−replace old new bs = if old `Set.member` bs then Set.insert new (Set.delete old bs) else bs
210+ | old `Set.member` bs = Set.insert new (Set.delete old bs)
211+ | otherwise = error (unwords [ "post-process: cannot replace name binding"
212+ , show old, "by", show new
213+ , "because it's not found in set"
151−-- TODO: I need to figure out how to conveniently replace a binding in a set.
152gtk3Hook :: Derivation -> Derivation -- https://github.com/NixOS/cabal2nix/issues/145
217gtk3Hook :: Derivation -> Derivation -- https://github.com/NixOS/cabal2nix/issues/145
153gtk3Hook = set (libraryDepends . pkgconfig . contains (pkg "gtk3")) True
218gtk3Hook = set (libraryDepends . pkgconfig . contains (pkg "gtk3")) True
154 . over (libraryDepends . pkgconfig) (Set.filter (\b -> view localName b /= "gtk3"))
219 . over (libraryDepends . pkgconfig) (Set.filter (\b -> view localName b /= "gtk3"))
@@ -165,13 +230,12 @@ gitAnnexHook = set phaseOverrides gitAnnexOverrides
166 gitAnnexOverrides = unlines
231 gitAnnexOverrides = unlines
167 [ "preConfigure = \"export HOME=$TEMPDIR; patchShebangs .\";"
232 [ "preConfigure = \"export HOME=$TEMPDIR; patchShebangs .\";"
168− , "installPhase = \"make PREFIX=$out BUILDER=: install\";"
233+ , "postBuild = ''"
170 , " ln -sf dist/build/git-annex/git-annex git-annex"
234 , " ln -sf dist/build/git-annex/git-annex git-annex"
171 , " ln -sf git-annex git-annex-shell"
235 , " ln -sf git-annex git-annex-shell"
172− , " export PATH+=\":$PWD\""
237+ , "installPhase = \"make PREFIX=$out BUILDER=: install install-completions\";"
238+ , "checkPhase = ''PATH+=\":$PWD\" git-annex test'';"
175 , "enableSharedExecutables = false;"
239 , "enableSharedExecutables = false;"
177 buildInputs = pkgs ["git","rsync","gnupg","curl","wget","lsof","openssh","which","bup","perl"]
241 buildInputs = pkgs ["git","rsync","gnupg","curl","wget","lsof","openssh","which","bup","perl"]
@@ -192,13 +256,13 @@ gfPhaseOverrides = unlines
192 , " sed -i \"s|numJobs (bf bi)++||\" ./Setup.hs"
256 , " sed -i \"s|numJobs (bf bi)++||\" ./Setup.hs"
193 -- Parallel compilation fails. Disable it.
257 -- Parallel compilation fails. Disable it.
195− , "preBuild = ''export LD_LIBRARY_PATH=`pwd`/dist/build:$LD_LIBRARY_PATH'';"
259+ , "preBuild = ''export LD_LIBRARY_PATH=`pwd`/dist/build''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH'';"
196 -- The build step itself, after having built the library, needs to be able
260 -- The build step itself, after having built the library, needs to be able
197 -- to find the library it just built in order to compile grammar files.
261 -- to find the library it just built in order to compile grammar files.
200wxcHook :: Derivation -> Derivation
264wxcHook :: Derivation -> Derivation
201−wxcHook drv = drv & libraryDepends . system %~ Set.union (Set.fromList [pkg "mesa", bind "pkgs.xorg.libX11"])
265+wxcHook drv = drv & libraryDepends . system %~ Set.union (Set.fromList [pkg "libGL", bind "pkgs.xorg.libX11"])
202 & libraryDepends . pkgconfig . contains (pkg "wxGTK") .~ True
266 & libraryDepends . pkgconfig . contains (pkg "wxGTK") .~ True
203 & phaseOverrides .~ wxcPostInstall (packageVersion drv)
267 & phaseOverrides .~ wxcPostInstall (packageVersion drv)
204 & runHaddock .~ False
268 & runHaddock .~ False
@@ -228,10 +292,8 @@ darcsInstallPostInstall = unlines
228xmonadPostInstall :: String
292xmonadPostInstall :: String
229xmonadPostInstall = unlines
293xmonadPostInstall = unlines
230 [ "postInstall = ''"
294 [ "postInstall = ''"
231− , " shopt -s globstar"
295+ , " install -D man/xmonad.1 ''${!outputDoc}/share/man/man1/xmonad.1"
232− , " mkdir -p $doc/share/man/man1"
296+ , " install -D man/xmonad.hs ''${!outputDoc}/share/doc/$name/sample-xmonad.hs"
233− , " mv \"$data/\"**\"/man/\"*[0-9] $doc/share/man/man1/"
234− , " rm \"$data/\"**\"/man/\"*"
@@ -298,8 +360,50 @@ webkitgtk24xHook = set (libraryDepends . pkgconfig . contains (pkg "webkitgtk24x
298opencvOverrides :: Derivation -> Derivation
360opencvOverrides :: Derivation -> Derivation
299opencvOverrides = set phaseOverrides "hardeningDisable = [ \"bindnow\" ];"
361opencvOverrides = set phaseOverrides "hardeningDisable = [ \"bindnow\" ];"
300 . over (libraryDepends . pkgconfig) (replace (pkg "opencv") (pkg "opencv3"))
362 . over (libraryDepends . pkgconfig) (replace (pkg "opencv") (pkg "opencv3"))
301− . set (configureFlags . contains "--with-gcc=${stdenv.cc}/bin/c++") True
302− . set (configureFlags . contains "--with-ld=${stdenv.cc}/bin/c++") True
304hspecCoreOverrides :: Derivation -> Derivation -- https://github.com/hspec/hspec/issues/330
364hspecCoreOverrides :: Derivation -> Derivation -- https://github.com/hspec/hspec/issues/330
305hspecCoreOverrides = set phaseOverrides "testTarget = \"--test-option=--skip --test-option='Test.Hspec.Core.Runner.hspecResult runs specs in parallel'\";"
365hspecCoreOverrides = set phaseOverrides "testTarget = \"--test-option=--skip --test-option='Test.Hspec.Core.Runner.hspecResult runs specs in parallel'\";"
367+cabal2nixOverrides :: Derivation -> Derivation
368+cabal2nixOverrides = set phaseOverrides $ unlines
370+ , " export PATH=\"$PWD/dist/build/cabal2nix:$PATH\""
371+ , " export HOME=\"$TMPDIR/home\""
375+gtkglextHook :: Derivation -> Derivation
376+gtkglextHook = over (libraryDepends . system) (Set.union (Set.fromList deps))
379+ deps = bind <$> [ "pkgs.gtk2"
382+ , "pkgs.xorg.libICE"
384+ , "pkgs.xorg.libXmu"
387+pandocPre26Overrides :: Derivation -> Derivation
388+pandocPre26Overrides = set phaseOverrides postInstall
390+ postInstall = unlines [ "postInstall = ''"
391+ , " mkdir -p $out/share"
392+ , " mv $data/*/*/man $out/share/"
396+pandocOverrides :: Derivation -> Derivation
397+pandocOverrides = set phaseOverrides postInstall
399+ postInstall = unlines [ "postInstall = ''"
400+ , " mkdir -p $out/share/man/man1"
401+ , " mv \"man/\"*.1 $out/share/man/man1/"
405+bustleOverrides :: Derivation -> Derivation
406+bustleOverrides = set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True
407+ . set (executableDepends . pkgconfig . contains "gio-unix = null") False
408+ . set (metaSection . license) (Known "stdenv.lib.licenses.lgpl21Plus")
409+ . set (metaSection . hydraPlatforms) allKnownPlatforms