git.iko.soy/typeable/cabal2nix
on 1663fb8 help sign in
243 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 == "GlomeVec" = deriv { buildTools = Set.insert "llvm" 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 == "idris" = deriv { buildTools = Set.insert "happy" buildTools, extraLibs = Set.insert "gmp" (Set.insert "boehmgc" extraLibs) }
68 | pname == "inline-c-cpp" = deriv { testDepends = Set.delete "stdc++" testDepends }
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 "z3" (Set.insert "ocaml" buildTools), configureFlags = Set.insert "-fbuild-external" configureFlags }
74 | pname == "liquidhaskell" = deriv { buildTools = Set.insert "z3" buildTools }
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 == "readline" = deriv { extraLibs = Set.insert "readline" (Set.insert "ncurses" extraLibs) }
90 | pname == "repa-algorithms" = deriv { extraLibs = Set.insert "llvm" 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 == "target" = deriv { buildTools = Set.insert "z3" buildTools }
101 | pname == "terminfo" = deriv { extraLibs = Set.insert "ncurses" extraLibs }
102 | pname == "threadscope" = deriv { configureFlags = Set.insert "--ghc-options=-rtsopts" configureFlags }
103 | pname == "thyme" = deriv { buildTools = Set.insert "cpphs" buildTools }
104 | pname == "vacuum" = deriv { extraLibs = Set.insert "ghc-paths" extraLibs }
105 | pname == "wxc" = deriv { extraLibs = Set.fromList ["wxGTK","mesa","libX11"] `Set.union` extraLibs
106 , phaseOverrides = wxcPostInstall version
107 }
108 | pname == "wxcore" = deriv { extraLibs = Set.fromList ["wxGTK","mesa","libX11"] `Set.union` extraLibs }
109 | pname == "X11" && version >= Version [1,6] []
110 = deriv { extraLibs = Set.fromList ["libXinerama","libXext","libXrender"] `Set.union` extraLibs }
111 | pname == "X11" = deriv { extraLibs = Set.insert "libXinerama" (Set.insert "libXext" extraLibs) }
112 | pname == "X11-xft" = deriv { extraLibs = Set.fromList ["pkgconfig","freetype","fontconfig"] `Set.union` extraLibs
113 , configureFlags = Set.insert "--extra-include-dirs=${freetype}/include/freetype2" configureFlags
114 }
115 | pname == "xmonad" = deriv { phaseOverrides = xmonadPostInstall }
117-- Unbreak packages during hackage2nix generation:
119 | pname == "hnetcdf" = deriv { testDepends = Set.delete "netcdf" testDepends }
120 | pname == "SDL2-ttf" = deriv { buildDepends = Set.delete "SDL2" buildDepends }
121 | pname == "jsaddle" = deriv { buildDepends = Set.delete "ghcjs-base" buildDepends, testDepends = Set.delete "ghcjs-base" testDepends }
122 | pname == "hzk" = deriv { testDepends = Set.delete "zookeeper_mt" testDepends, buildTools = Set.insert "zookeeper_mt" buildTools }
123 | pname == "zip-archive" = deriv { testDepends = Set.delete "zip" testDepends, buildTools = Set.insert "zip" buildTools }
124 | otherwise = deriv
126ghcModPostInstall :: String -> Version -> String
127ghcModPostInstall pname version = unlines
128 [ "configureFlags = \"--datasubdir=" ++ pname ++ "-" ++ display version ++ "\";"
129 , "postInstall = ''"
130 , " cd $out/share/" ++ pname ++ "-" ++ display version
131 , " make"
132 , " rm Makefile"
133 , " cd .."
134 , " ensureDir \"$out/share/emacs\""
135 , " mv " ++ pname ++ "-" ++ display version ++ " emacs/site-lisp"
136 , "'';"
137 ]
139wxcPostInstall :: Version -> String
140wxcPostInstall version = unlines
141 [ "postInstall = ''"
142 , " cp -v dist/build/libwxc.so." ++ display version ++ " $out/lib/libwxc.so"
143 , "'';"
144 ]
146cabalInstallPostInstall :: String
147cabalInstallPostInstall = unlines
148 [ "postInstall = ''"
149 , " mkdir $out/etc"
150 , " mv bash-completion $out/etc/bash_completion.d"
151 , "'';"
152 ]
154darcsInstallPostInstall :: String
155darcsInstallPostInstall = unlines
156 [ "postInstall = ''"
157 , " mkdir -p $out/etc/bash_completion.d"
158 , " mv contrib/darcs_completion $out/etc/bash_completion.d/darcs"
159 , "'';"
160 ]
162xmonadPostInstall :: String
163xmonadPostInstall = unlines
164 [ "postInstall = ''"
165 , " shopt -s globstar"
166 , " mkdir -p $out/share/man/man1"
167 , " mv \"$out/\"**\"/man/\"*.1 $out/share/man/man1/"
168 , "'';"
169 ]
171gitAnnexOverrides :: String
172gitAnnexOverrides = unlines
173 [ "preConfigure = \"export HOME=$TEMPDIR\";"
174 , "checkPhase = ''"
175 , " cp dist/build/git-annex/git-annex git-annex"
176 , " ./git-annex test"
177 , "'';"
178 ]
180ghciPostInstall :: String
181ghciPostInstall = unlines
182 [ "postInstall = ''"
183 , " ensureDir \"$out/share/ghci\""
184 , " ln -s \"$out/share/$pname-$version/ghci\" \"$out/share/ghci/$pname\""
185 , "'';"
186 ]
188hfusePreConfigure :: String
189hfusePreConfigure = unlines
190 [ "preConfigure = ''"
191 , " sed -i -e \"s@ Extra-Lib-Dirs: /usr/local/lib@ Extra-Lib-Dirs: ${fuse}/lib@\" HFuse.cabal"
192 , "'';"
193 ]
195ghcPathsPatches :: String
196ghcPathsPatches = "patches = [ ./ghc-paths-nix.patch ];"
198lhs2texPostInstall :: String
199lhs2texPostInstall = unlines
200 [ "postInstall = ''"
201 , " mkdir -p \"$out/share/doc/$name\""
202 , " cp doc/Guide2.pdf $out/share/doc/$name"
203 , " mkdir -p \"$out/nix-support\""
204 , "'';"
205 ]
207ncursesPatchPhase :: String
208ncursesPatchPhase = "patchPhase = \"find . -type f -exec sed -i -e 's|ncursesw/||' {} \\\\;\";"
210agdaPostInstall :: String
211agdaPostInstall = unlines
212 [ "postInstall = ''"
213 , " $out/bin/agda -c --no-main $(find $out/share -name Primitive.agda)"
214 , " $out/bin/agda-mode compile"
215 , "'';"
216 ]
218structuredHaskellModePostInstall :: String
219structuredHaskellModePostInstall = unlines
220 [ "postInstall = ''"
221 , " emacs -L elisp --batch -f batch-byte-compile \"elisp/\"*.el"
222 , " install -d $out/share/emacs/site-lisp"
223 , " install \"elisp/\"*.el \"elisp/\"*.elc $out/share/emacs/site-lisp"
224 , "'';"
225 ]
227sloanePostInstall :: String
228sloanePostInstall = unlines
229 [ "postInstall = ''"
230 , " mkdir -p $out/share/man/man1"
231 , " cp sloane.1 $out/share/man/man1/"
232 , "'';"
233 ]
235haddockPreCheck :: String
236haddockPreCheck = "preCheck = \"unset GHC_PACKAGE_PATH\";"
238ghcParserPatchPhase :: String
239ghcParserPatchPhase = unlines
240 [ "patchPhase = ''"
241 , " substituteInPlace build-parser.sh --replace \"/bin/bash\" \"$SHELL\""
242 , "'';"
243 ]