git.iko.soy/typeable/cabal2nix
on d141dba help sign in
242 lines 13 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
41 , buildTools = Set.insert "emacs" (Set.insert "makeWrapper" buildTools) }
42 | pname == "ghc-parser" = deriv { buildTools = Set.insert "cpphs" (Set.insert "happy" buildTools)
43 , phaseOverrides = ghcParserPatchPhase }
44 | pname == "ghc-paths" = deriv { phaseOverrides = ghcPathsPatches }
45 | pname == "ghc-vis" = deriv { phaseOverrides = ghciPostInstall }
46 | pname == "git-annex" = deriv { phaseOverrides = gitAnnexOverrides
47 , buildTools = Set.fromList ["git","rsync","gnupg1","curl","wget","lsof","openssh","which","bup","perl"] `Set.union` buildTools }
48 | pname == "github-backup" = deriv { buildTools = Set.insert "git" buildTools }
49 | pname == "gloss-raster" = deriv { extraLibs = Set.insert "llvm" extraLibs }
50 | pname == "GLUT" = deriv { extraLibs = Set.fromList ["glut","libSM","libICE","libXmu","libXi","mesa"] `Set.union` extraLibs }
51 | pname == "gtkglext" = deriv { pkgConfDeps = Set.insert "pangox_compat" pkgConfDeps }
52 | pname == "gtk2hs-buildtools"= deriv { buildDepends = Set.insert "hashtables" buildDepends }
53 | pname == "haddock" && version < Version [2,14] []
54 = deriv { buildTools = Set.insert "alex" (Set.insert "happy" buildTools) }
55 | pname == "haddock" = deriv { phaseOverrides = haddockPreCheck }
56 | pname == "happy" = deriv { buildTools = Set.insert "perl" buildTools }
57 | pname == "haskeline" = deriv { buildDepends = Set.insert "utf8-string" buildDepends }
58 | pname == "haskell-src" = deriv { buildTools = Set.insert "happy" buildTools }
59 | pname == "haskell-src-meta" = deriv { buildDepends = Set.insert "uniplate" buildDepends }
60 | pname == "HFuse" = deriv { phaseOverrides = hfusePreConfigure }
61 | pname == "hlibgit2" = deriv { buildTools = Set.insert "git" buildTools }
62 | pname == "HList" = deriv { buildTools = Set.insert "diffutils" buildTools }
63 | pname == "hmatrix" = deriv { extraLibs = Set.insert "liblapack" (Set.insert "blas" (Set.filter (/= "lapack") extraLibs)) }
64 | pname == "hmatrix-special" = deriv { extraLibs = Set.insert "gsl" extraLibs }
65 | pname == "hoogle" = deriv { testTarget = "--test-option=--no-net" }
66 | pname == "hspec" = deriv { doCheck = False }
67 | pname == "GlomeVec" = deriv { buildTools = Set.insert "llvm" buildTools }
68 | pname == "idris" = deriv { buildTools = Set.insert "happy" buildTools, extraLibs = Set.insert "gmp" (Set.insert "boehmgc" extraLibs) }
69 | pname == "language-c-quote" = deriv { buildTools = Set.insert "alex" (Set.insert "happy" buildTools) }
70 | pname == "language-java" = deriv { buildDepends = Set.insert "syb" buildDepends }
71 | pname == "lhs2tex" = deriv { extraLibs = Set.insert "texLive" extraLibs, phaseOverrides = lhs2texPostInstall }
72 | pname == "libffi" = deriv { extraLibs = Set.delete "ffi" extraLibs }
73 | pname == "liquid-fixpoint" = deriv { buildTools = Set.insert "ocaml" buildTools, configureFlags = Set.insert "-fbuild-external" configureFlags }
74 | pname == "liquidhaskell" = deriv { doCheck = False } -- test-suite requires cvc4 or z3
75 | pname == "llvm-base" = deriv { extraLibs = Set.insert "llvm" extraLibs }
76 | pname == "llvm-general" = deriv { doCheck = False }
77 | pname == "llvm-general-pure"= deriv { doCheck = False }
78 | pname == "MFlow" = deriv { buildTools = Set.insert "cpphs" buildTools }
79 | pname == "multiarg" = deriv { buildDepends = Set.insert "utf8-string" buildDepends }
80 | pname == "mysql" = deriv { buildTools = Set.insert "mysql" buildTools, extraLibs = Set.insert "zlib" (Set.insert "openssl" extraLibs) }
81 | pname == "ncurses" = deriv { phaseOverrides = ncursesPatchPhase }
82 | pname == "Omega" = deriv { testDepends = Set.delete "stdc++" testDepends }
83 | pname == "OpenAL" = deriv { extraLibs = Set.insert "openal" extraLibs }
84 | pname == "OpenGL" = deriv { extraLibs = Set.insert "mesa" (Set.insert "libX11" extraLibs) }
85 | pname == "pandoc" = deriv { buildDepends = Set.insert "alex" (Set.insert "happy" buildDepends) }
86 | pname == "pcap" = deriv { extraLibs = Set.insert "libpcap" extraLibs }
87 | pname == "persistent" = deriv { extraLibs = Set.insert "sqlite3" extraLibs }
88 | pname == "purescript" = deriv { buildTools = Set.insert "nodejs" buildTools }
89 | pname == "repa-algorithms" = deriv { extraLibs = Set.insert "llvm" extraLibs }
90 | pname == "readline" = deriv { extraLibs = Set.insert "readline" (Set.insert "ncurses" extraLibs) }
91 | pname == "repa-examples" = deriv { extraLibs = Set.insert "llvm" extraLibs }
92 | pname == "saltine" = deriv { extraLibs = Set.map (\x -> if x == "sodium" then "libsodium" else x) extraLibs }
93 | pname == "SDL-image" = deriv { extraLibs = Set.insert "SDL_image" extraLibs }
94 | pname == "SDL-mixer" = deriv { extraLibs = Set.insert "SDL_mixer" extraLibs }
95 | pname == "SDL-ttf" = deriv { extraLibs = Set.insert "SDL_ttf" extraLibs }
96 | pname == "sloane" = deriv { phaseOverrides = sloanePostInstall }
97 | pname == "structured-haskell-mode" = deriv { buildTools = Set.insert "emacs" buildTools
98 , phaseOverrides = structuredHaskellModePostInstall
99 }
100 | pname == "terminfo" = deriv { extraLibs = Set.insert "ncurses" extraLibs }
101 | pname == "threadscope" = deriv { configureFlags = Set.insert "--ghc-options=-rtsopts" configureFlags }
102 | pname == "thyme" = deriv { buildTools = Set.insert "cpphs" buildTools }
103 | pname == "vacuum" = deriv { extraLibs = Set.insert "ghc-paths" extraLibs }
104 | pname == "wxc" = deriv { extraLibs = Set.fromList ["wxGTK","mesa","libX11"] `Set.union` extraLibs
105 , phaseOverrides = wxcPostInstall version
106 }
107 | pname == "wxcore" = deriv { extraLibs = Set.fromList ["wxGTK","mesa","libX11"] `Set.union` extraLibs }
108 | pname == "X11" && version >= Version [1,6] []
109 = deriv { extraLibs = Set.fromList ["libXinerama","libXext","libXrender"] `Set.union` extraLibs }
110 | pname == "X11" = deriv { extraLibs = Set.insert "libXinerama" (Set.insert "libXext" extraLibs) }
111 | pname == "X11-xft" = deriv { extraLibs = Set.fromList ["pkgconfig","freetype","fontconfig"] `Set.union` extraLibs
112 , configureFlags = Set.insert "--extra-include-dirs=${freetype}/include/freetype2" configureFlags
113 }
114 | pname == "xmonad" = deriv { phaseOverrides = xmonadPostInstall }
116-- Unbreak packages during hackage2nix generation:
118 | pname == "hnetcdf" = deriv { testDepends = Set.delete "netcdf" testDepends }
119 | pname == "SDL2-ttf" = deriv { buildDepends = Set.delete "SDL2" buildDepends }
120 | pname == "jsaddle" = deriv { buildDepends = Set.delete "ghcjs-base" buildDepends, testDepends = Set.delete "ghcjs-base" testDepends }
121 | pname == "hzk" = deriv { testDepends = Set.delete "zookeeper_mt" testDepends, buildTools = Set.insert "zookeeper_mt" buildTools }
122 | pname == "zip-archive" = deriv { testDepends = Set.delete "zip" testDepends, buildTools = Set.insert "zip" buildTools }
123 | otherwise = deriv
125ghcModPostInstall :: String -> Version -> String
126ghcModPostInstall pname version = unlines
127 [ "configureFlags = \"--datasubdir=" ++ pname ++ "-" ++ display version ++ "\";"
128 , "postInstall = ''"
129 , " cd $out/share/" ++ pname ++ "-" ++ display version
130 , " make"
131 , " rm Makefile"
132 , " cd .."
133 , " ensureDir \"$out/share/emacs\""
134 , " mv " ++ pname ++ "-" ++ display version ++ " emacs/site-lisp"
135 , "'';"
136 ]
138wxcPostInstall :: Version -> String
139wxcPostInstall version = unlines
140 [ "postInstall = ''"
141 , " cp -v dist/build/libwxc.so." ++ display version ++ " $out/lib/libwxc.so"
142 , "'';"
143 ]
145cabalInstallPostInstall :: String
146cabalInstallPostInstall = unlines
147 [ "postInstall = ''"
148 , " mkdir $out/etc"
149 , " mv bash-completion $out/etc/bash_completion.d"
150 , "'';"
151 ]
153darcsInstallPostInstall :: String
154darcsInstallPostInstall = unlines
155 [ "postInstall = ''"
156 , " mkdir -p $out/etc/bash_completion.d"
157 , " mv contrib/darcs_completion $out/etc/bash_completion.d/darcs"
158 , "'';"
159 ]
161xmonadPostInstall :: String
162xmonadPostInstall = unlines
163 [ "postInstall = ''"
164 , " shopt -s globstar"
165 , " mkdir -p $out/share/man/man1"
166 , " mv \"$out/\"**\"/man/\"*.1 $out/share/man/man1/"
167 , "'';"
168 ]
170gitAnnexOverrides :: String
171gitAnnexOverrides = unlines
172 [ "preConfigure = \"export HOME=$TEMPDIR\";"
173 , "checkPhase = ''"
174 , " cp dist/build/git-annex/git-annex git-annex"
175 , " ./git-annex test"
176 , "'';"
177 ]
179ghciPostInstall :: String
180ghciPostInstall = unlines
181 [ "postInstall = ''"
182 , " ensureDir \"$out/share/ghci\""
183 , " ln -s \"$out/share/$pname-$version/ghci\" \"$out/share/ghci/$pname\""
184 , "'';"
185 ]
187hfusePreConfigure :: String
188hfusePreConfigure = unlines
189 [ "preConfigure = ''"
190 , " sed -i -e \"s@ Extra-Lib-Dirs: /usr/local/lib@ Extra-Lib-Dirs: ${fuse}/lib@\" HFuse.cabal"
191 , "'';"
192 ]
194ghcPathsPatches :: String
195ghcPathsPatches = "patches = [ ./ghc-paths-nix.patch ];"
197lhs2texPostInstall :: String
198lhs2texPostInstall = unlines
199 [ "postInstall = ''"
200 , " mkdir -p \"$out/share/doc/$name\""
201 , " cp doc/Guide2.pdf $out/share/doc/$name"
202 , " mkdir -p \"$out/nix-support\""
203 , "'';"
204 ]
206ncursesPatchPhase :: String
207ncursesPatchPhase = "patchPhase = \"find . -type f -exec sed -i -e 's|ncursesw/||' {} \\\\;\";"
209agdaPostInstall :: String
210agdaPostInstall = unlines
211 [ "postInstall = ''"
212 , " $out/bin/agda -c --no-main $(find $out/share -name Primitive.agda)"
213 , " $out/bin/agda-mode compile"
214 , "'';"
215 ]
217structuredHaskellModePostInstall :: String
218structuredHaskellModePostInstall = unlines
219 [ "postInstall = ''"
220 , " emacs -L elisp --batch -f batch-byte-compile \"elisp/\"*.el"
221 , " install -d $out/share/emacs/site-lisp"
222 , " install \"elisp/\"*.el \"elisp/\"*.elc $out/share/emacs/site-lisp"
223 , "'';"
224 ]
226sloanePostInstall :: String
227sloanePostInstall = unlines
228 [ "postInstall = ''"
229 , " mkdir -p $out/share/man/man1"
230 , " cp sloane.1 $out/share/man/man1/"
231 , "'';"
232 ]
234haddockPreCheck :: String
235haddockPreCheck = "preCheck = \"unset GHC_PACKAGE_PATH\";"
237ghcParserPatchPhase :: String
238ghcParserPatchPhase = unlines
239 [ "patchPhase = ''"
240 , " substituteInPlace build-parser.sh --replace \"/bin/bash\" \"$SHELL\""
241 , "'';"
242 ]