git.iko.soy/typeable/cabal2nix
on bc9bdb2 help sign in
260 lines 14 kB history raw
1{-# LANGUAGE RecordWildCards #-}
3module Cabal2Nix.PostProcess ( postProcess ) where
5import qualified Data.Set as Set
6import Distribution.Nixpkgs.Haskell
7import Distribution.Text ( display )
9postProcess :: Derivation -> Derivation
10postProcess = postProcess' . fixGtkBuilds
12fixGtkBuilds :: Derivation -> Derivation
13fixGtkBuilds deriv@(MkDerivation {..}) = deriv { pkgConfDeps = pkgConfDeps `Set.difference` buildDepends }
15postProcess' :: Derivation -> Derivation
16postProcess' deriv@(MkDerivation {..})
17 | pname == "aeson" && version > Version [0,7] []
18 = deriv { buildDepends = Set.insert "blaze-builder" buildDepends }
19 | pname == "Agda" = deriv { buildTools = Set.insert "emacs" buildTools, phaseOverrides = agdaPostInstall }
20 | pname == "alex" && version < Version [3,1] []
21 = deriv { buildTools = Set.insert "perl" buildTools }
22 | pname == "alex" && version >= Version [3,1] []
23 = deriv { buildTools = Set.insert "perl" (Set.insert "happy" buildTools) }
24 | pname == "apache-md5" = deriv { testDepends = Set.delete "crypto" testDepends }
25 | pname == "bindings-GLFW" = deriv { extraLibs = Set.insert "libXext" (Set.insert "libXfixes" extraLibs) }
26 | pname == "bits-extras" = deriv { configureFlags = Set.insert "--ghc-option=-lgcc_s" configureFlags
27 , extraLibs = Set.filter (/= "gcc_s") extraLibs
28 }
29 | pname == "Cabal" = deriv { phaseOverrides = "preCheck = \"unset GHC_PACKAGE_PATH; export HOME=$NIX_BUILD_TOP\";" }
30 | pname == "cabal-bounds" = deriv { buildTools = Set.insert "cabal-install" buildTools }
31 | pname == "cabal-install" && version >= Version [0,14] []
32 = deriv { phaseOverrides = cabalInstallPostInstall }
33 | pname == "darcs" = deriv { phaseOverrides = darcsInstallPostInstall }
34 | pname == "dns" = deriv { testTarget = "spec" }
35 | pname == "editline" = deriv { extraLibs = Set.insert "libedit" extraLibs }
36 | pname == "epic" = deriv { extraLibs = Set.insert "gmp" (Set.insert "boehmgc" extraLibs)
37 , buildTools = Set.insert "happy" buildTools
38 }
39 | pname == "ghc-heap-view" = deriv { phaseOverrides = ghciPostInstall }
40 | pname == "ghc-mod" = deriv { phaseOverrides = ghcModPostInstall pname version, buildTools = Set.insert "emacs" buildTools }
41 | pname == "ghc-parser" = deriv { buildTools = Set.insert "cpphs" (Set.insert "happy" buildTools)
42 , phaseOverrides = ghcParserPatchPhase }
43 | pname == "ghc-paths" = deriv { phaseOverrides = ghcPathsPatches }
44 | pname == "ghc-vis" = deriv { phaseOverrides = ghciPostInstall }
45 | pname == "git-annex" = deriv { phaseOverrides = gitAnnexOverrides
46 , buildTools = Set.fromList ["git","rsync","gnupg","curl","wget","lsof","openssh","which","bup","perl"] `Set.union` buildTools }
47 | pname == "github-backup" = deriv { buildTools = Set.insert "git" buildTools }
48 | pname == "gloss-raster" = deriv { extraLibs = Set.insert "llvm" extraLibs }
49 | pname == "GLUT" = deriv { extraLibs = Set.fromList ["glut","libSM","libICE","libXmu","libXi","mesa"] `Set.union` extraLibs }
50 | pname == "gtkglext" = deriv { pkgConfDeps = Set.insert "pangox_compat" pkgConfDeps }
51 | pname == "gtk2hs-buildtools"= deriv { buildDepends = Set.insert "hashtables" buildDepends }
52 | pname == "haddock" && version < Version [2,14] []
53 = deriv { buildTools = Set.insert "alex" (Set.insert "happy" buildTools) }
54 | pname == "gf" = deriv { phaseOverrides = gfPhaseOverrides
55 , doCheck = False }
56 | pname == "GlomeVec" = deriv { buildTools = Set.insert "llvm" buildTools }
57 | pname == "haddock" = deriv { phaseOverrides = haddockPreCheck }
58 | pname == "happy" = deriv { buildTools = Set.insert "perl" buildTools }
59 | pname == "haskeline" = deriv { buildDepends = Set.insert "utf8-string" buildDepends }
60 | pname == "haskell-src" = deriv { buildTools = Set.insert "happy" buildTools }
61 | pname == "haskell-src-meta" = deriv { buildDepends = Set.insert "uniplate" buildDepends }
62 | pname == "HFuse" = deriv { phaseOverrides = hfusePreConfigure }
63 | pname == "hlibgit2" = deriv { buildTools = Set.insert "git" buildTools }
64 | pname == "HList" = deriv { buildTools = Set.insert "diffutils" buildTools }
65 | pname == "hmatrix" = deriv { extraLibs = Set.insert "liblapack" (Set.insert "blas" (Set.filter (/= "lapack") extraLibs)) }
66 | pname == "hmatrix-special" = deriv { extraLibs = Set.insert "gsl" extraLibs }
67 | pname == "hoogle" = deriv { testTarget = "--test-option=--no-net" }
68 | pname == "hspec" = deriv { doCheck = False }
69 | pname == "idris" = deriv { buildTools = Set.insert "happy" buildTools, extraLibs = Set.insert "gmp" (Set.insert "boehmgc" extraLibs) }
70 | pname == "inline-c-cpp" = deriv { testDepends = Set.delete "stdc++" testDepends }
71 | pname == "language-c-quote" = deriv { buildTools = Set.insert "alex" (Set.insert "happy" buildTools) }
72 | pname == "language-java" = deriv { buildDepends = Set.insert "syb" buildDepends }
73 | pname == "lhs2tex" = deriv { extraLibs = Set.insert "texLive" extraLibs, phaseOverrides = lhs2texPostInstall }
74 | pname == "libffi" = deriv { extraLibs = Set.delete "ffi" extraLibs }
75 | pname == "liquid-fixpoint" = deriv { buildTools = Set.insert "z3" (Set.insert "ocaml" buildTools), configureFlags = Set.insert "-fbuild-external" configureFlags }
76 | pname == "liquidhaskell" = deriv { buildTools = Set.insert "z3" buildTools }
77 | pname == "llvm-base" = deriv { extraLibs = Set.insert "llvm" extraLibs }
78 | pname == "llvm-general" = deriv { doCheck = False }
79 | pname == "llvm-general-pure"= deriv { doCheck = False }
80 | pname == "MFlow" = deriv { buildTools = Set.insert "cpphs" buildTools }
81 | pname == "multiarg" = deriv { buildDepends = Set.insert "utf8-string" buildDepends }
82 | pname == "mysql" = deriv { buildTools = Set.insert "mysql" buildTools, extraLibs = Set.insert "zlib" (Set.insert "openssl" extraLibs) }
83 | pname == "ncurses" = deriv { phaseOverrides = ncursesPatchPhase }
84 | pname == "Omega" = deriv { testDepends = Set.delete "stdc++" testDepends }
85 | pname == "OpenAL" = deriv { extraLibs = Set.insert "openal" extraLibs }
86 | pname == "OpenGL" = deriv { extraLibs = Set.insert "mesa" (Set.insert "libX11" extraLibs) }
87 | pname == "pandoc" = deriv { buildDepends = Set.insert "alex" (Set.insert "happy" buildDepends) }
88 | pname == "pcap" = deriv { extraLibs = Set.insert "libpcap" extraLibs }
89 | pname == "persistent" = deriv { extraLibs = Set.insert "sqlite3" extraLibs }
90 | pname == "purescript" = deriv { buildTools = Set.insert "nodejs" buildTools }
91 | pname == "readline" = deriv { extraLibs = Set.insert "readline" (Set.insert "ncurses" extraLibs) }
92 | pname == "repa-algorithms" = deriv { extraLibs = Set.insert "llvm" extraLibs }
93 | pname == "repa-examples" = deriv { extraLibs = Set.insert "llvm" extraLibs }
94 | pname == "saltine" = deriv { extraLibs = Set.map (\x -> if x == "sodium" then "libsodium" else x) extraLibs }
95 | pname == "SDL-image" = deriv { extraLibs = Set.insert "SDL_image" extraLibs }
96 | pname == "SDL-mixer" = deriv { extraLibs = Set.insert "SDL_mixer" extraLibs }
97 | pname == "SDL-ttf" = deriv { extraLibs = Set.insert "SDL_ttf" extraLibs }
98 | pname == "sloane" = deriv { phaseOverrides = sloanePostInstall }
99 | pname == "structured-haskell-mode" = deriv { buildTools = Set.insert "emacs" buildTools
100 , phaseOverrides = structuredHaskellModePostInstall
101 }
102 | pname == "target" = deriv { buildTools = Set.insert "z3" buildTools }
103 | pname == "terminfo" = deriv { extraLibs = Set.insert "ncurses" extraLibs }
104 | pname == "threadscope" = deriv { configureFlags = Set.insert "--ghc-options=-rtsopts" configureFlags }
105 | pname == "thyme" = deriv { buildTools = Set.insert "cpphs" buildTools }
106 | pname == "vacuum" = deriv { extraLibs = Set.insert "ghc-paths" extraLibs }
107 | pname == "wxc" = deriv { extraLibs = Set.fromList ["wxGTK","mesa","libX11"] `Set.union` extraLibs
108 , phaseOverrides = wxcPostInstall version
109 }
110 | pname == "wxcore" = deriv { extraLibs = Set.fromList ["wxGTK","mesa","libX11"] `Set.union` extraLibs }
111 | pname == "X11" && version >= Version [1,6] []
112 = deriv { extraLibs = Set.fromList ["libXinerama","libXext","libXrender"] `Set.union` extraLibs }
113 | pname == "X11" = deriv { extraLibs = Set.insert "libXinerama" (Set.insert "libXext" extraLibs) }
114 | pname == "X11-xft" = deriv { extraLibs = Set.fromList ["pkgconfig","freetype","fontconfig"] `Set.union` extraLibs
115 , configureFlags = Set.insert "--extra-include-dirs=${freetype}/include/freetype2" configureFlags
116 }
117 | pname == "xmonad" = deriv { phaseOverrides = xmonadPostInstall }
119-- Unbreak packages during hackage2nix generation:
121 | pname == "hnetcdf" = deriv { testDepends = Set.delete "netcdf" testDepends }
122 | pname == "SDL2-ttf" = deriv { buildDepends = Set.delete "SDL2" buildDepends }
123 | pname == "jsaddle" = deriv { buildDepends = Set.delete "ghcjs-base" buildDepends, testDepends = Set.delete "ghcjs-base" testDepends }
124 | pname == "hzk" = deriv { testDepends = Set.delete "zookeeper_mt" testDepends, buildTools = Set.insert "zookeeper_mt" buildTools }
125 | pname == "z3" = deriv { phaseOverrides = "preBuild = stdenv.lib.optionalString stdenv.isDarwin \"export DYLD_LIBRARY_PATH=${z3}/lib\";" }
126 | pname == "zip-archive" = deriv { testDepends = Set.delete "zip" testDepends, buildTools = Set.insert "zip" buildTools }
127 | otherwise = deriv
129ghcModPostInstall :: String -> Version -> String
130ghcModPostInstall pname version = unlines
131 [ "configureFlags = \"--datasubdir=" ++ pname ++ "-" ++ display version ++ "\";"
132 , "postInstall = ''"
133 , " cd $out/share/" ++ pname ++ "-" ++ display version
134 , " make"
135 , " rm Makefile"
136 , " cd .."
137 , " ensureDir \"$out/share/emacs\""
138 , " mv " ++ pname ++ "-" ++ display version ++ " emacs/site-lisp"
139 , "'';"
140 ]
142wxcPostInstall :: Version -> String
143wxcPostInstall version = unlines
144 [ "postInstall = ''"
145 , " cp -v dist/build/libwxc.so." ++ display version ++ " $out/lib/libwxc.so"
146 , "'';"
147 ]
149cabalInstallPostInstall :: String
150cabalInstallPostInstall = unlines
151 [ "postInstall = ''"
152 , " mkdir $out/etc"
153 , " mv bash-completion $out/etc/bash_completion.d"
154 , "'';"
155 ]
157darcsInstallPostInstall :: String
158darcsInstallPostInstall = unlines
159 [ "postInstall = ''"
160 , " mkdir -p $out/etc/bash_completion.d"
161 , " mv contrib/darcs_completion $out/etc/bash_completion.d/darcs"
162 , "'';"
163 ]
165xmonadPostInstall :: String
166xmonadPostInstall = unlines
167 [ "postInstall = ''"
168 , " shopt -s globstar"
169 , " mkdir -p $out/share/man/man1"
170 , " mv \"$out/\"**\"/man/\"*.1 $out/share/man/man1/"
171 , "'';"
172 ]
174gitAnnexOverrides :: String
175gitAnnexOverrides = unlines
176 [ "preConfigure = \"export HOME=$TEMPDIR\";"
177 , "checkPhase = ''"
178 , " cp dist/build/git-annex/git-annex git-annex"
179 , " ./git-annex test"
180 , "'';"
181 ]
183ghciPostInstall :: String
184ghciPostInstall = unlines
185 [ "postInstall = ''"
186 , " ensureDir \"$out/share/ghci\""
187 , " ln -s \"$out/share/$pname-$version/ghci\" \"$out/share/ghci/$pname\""
188 , "'';"
189 ]
191hfusePreConfigure :: String
192hfusePreConfigure = unlines
193 [ "preConfigure = ''"
194 , " sed -i -e \"s@ Extra-Lib-Dirs: /usr/local/lib@ Extra-Lib-Dirs: ${fuse}/lib@\" HFuse.cabal"
195 , "'';"
196 ]
198ghcPathsPatches :: String
199ghcPathsPatches = "patches = [ ./ghc-paths-nix.patch ];"
201lhs2texPostInstall :: String
202lhs2texPostInstall = unlines
203 [ "postInstall = ''"
204 , " mkdir -p \"$out/share/doc/$name\""
205 , " cp doc/Guide2.pdf $out/share/doc/$name"
206 , " mkdir -p \"$out/nix-support\""
207 , "'';"
208 ]
210ncursesPatchPhase :: String
211ncursesPatchPhase = "patchPhase = \"find . -type f -exec sed -i -e 's|ncursesw/||' {} \\\\;\";"
213agdaPostInstall :: String
214agdaPostInstall = unlines
215 [ "postInstall = ''"
216 , " $out/bin/agda -c --no-main $(find $out/share -name Primitive.agda)"
217 , " $out/bin/agda-mode compile"
218 , "'';"
219 ]
221structuredHaskellModePostInstall :: String
222structuredHaskellModePostInstall = unlines
223 [ "postInstall = ''"
224 , " emacs -L elisp --batch -f batch-byte-compile \"elisp/\"*.el"
225 , " install -d $out/share/emacs/site-lisp"
226 , " install \"elisp/\"*.el \"elisp/\"*.elc $out/share/emacs/site-lisp"
227 , "'';"
228 ]
230sloanePostInstall :: String
231sloanePostInstall = unlines
232 [ "postInstall = ''"
233 , " mkdir -p $out/share/man/man1"
234 , " cp sloane.1 $out/share/man/man1/"
235 , "'';"
236 ]
238haddockPreCheck :: String
239haddockPreCheck = "preCheck = \"unset GHC_PACKAGE_PATH\";"
241ghcParserPatchPhase :: String
242ghcParserPatchPhase = unlines
243 [ "patchPhase = ''"
244 , " substituteInPlace build-parser.sh --replace \"/bin/bash\" \"$SHELL\""
245 , "'';"
246 ]
248gfPhaseOverrides :: String
249gfPhaseOverrides = unlines
250 [ "postPatch = ''"
251 , " sed -i \"s|\\\"-s\\\"|\\\"\\\"|\" ./Setup.hs"
252 -- Disable silent compilation. Compiling takes long, it is best to see some
253 -- output, otherwise it looks like the build step has stalled.
254 , " sed -i \"s|numJobs (bf bi)++||\" ./Setup.hs"
255 -- Parallel compilation fails. Disable it.
256 , "'';"
257 , "preBuild = ''export LD_LIBRARY_PATH=`pwd`/dist/build:$LD_LIBRARY_PATH'';"
258 -- The build step itself, after having built the library, needs to be able
259 -- to find the library it just built in order to compile grammar files.
260 ]