1{-# LANGUAGE RecordWildCards #-}
3module Cabal2Nix.PostProcess ( postProcess ) where
5import Distribution.NixOS.Derivation.Cabal
8postProcess :: Derivation -> Derivation
9postProcess deriv@(MkDerivation {..})
10 | pname == "alex" && version < Version [3,1] []
11 = deriv { buildTools = "perl":buildTools }
12 | pname == "alex" && version >= Version [3,1] []
13 = deriv { buildTools = "perl":"happy":buildTools }
14 | pname == "cabal2nix" = deriv { doCheck = True, phaseOverrides = cabal2nixDoCheckHook }
15 | pname == "cabal-install" && version >= Version [0,14] []
16 = deriv { phaseOverrides = cabalInstallPostInstall }
17 | pname == "cairo" = deriv { extraLibs = "pkgconfig":"libc":"cairo":"zlib":extraLibs }
18 | pname == "cuda" = deriv { phaseOverrides = cudaConfigurePhase, extraLibs = "cudatoolkit":"nvidia_x11":"self.stdenv.gcc":extraLibs }
19 | pname == "darcs" = deriv { phaseOverrides = darcsInstallPostInstall }
20 | pname == "dns" = deriv { testTarget = "spec" }
21 | pname == "doctest" = deriv { runHaddock = True, phaseOverrides = doctestNoHaddock }
22 | pname == "editline" = deriv { extraLibs = "libedit":extraLibs }
23 | pname == "epic" = deriv { extraLibs = "gmp":"boehmgc":extraLibs, buildTools = "happy":buildTools }
24 | pname == "ghc-heap-view" = deriv { phaseOverrides = ghciPostInstall }
25 | pname == "ghc-mod" = deriv { phaseOverrides = ghcModPostInstall, buildTools = "emacs":buildTools }
26 | pname == "ghc-paths" = deriv { phaseOverrides = ghcPathsPatches }
27 | pname == "ghc-vis" = deriv { phaseOverrides = ghciPostInstall }
28 | pname == "git-annex" = deriv { phaseOverrides = gitAnnexOverrides, buildTools = "git":"rsync":"gnupg1":"curl":"lsof":"openssh":"which":"bup":"perl":buildTools }
29 | pname == "github-backup" = deriv { buildTools = "git":buildTools }
30 | pname == "glade" = deriv { extraLibs = "pkgconfig":"libc":extraLibs, pkgConfDeps = "gtkC":delete "gtk" pkgConfDeps }
31 | pname == "glib" = deriv { extraLibs = "pkgconfig":"libc":extraLibs }
32 | pname == "GLUT" = deriv { extraLibs = "glut":"libSM":"libICE":"libXmu":"libXi":"mesa":extraLibs }
33 | pname == "gtk" = deriv { extraLibs = "pkgconfig":"libc":extraLibs, buildDepends = delete "gio" buildDepends }
34 | pname == "gtksourceview2" = deriv { extraLibs = "pkgconfig":"libc":extraLibs }
35 | pname == "haddock" = deriv { buildTools = "alex":"happy":buildTools }
36 | pname == "happy" = deriv { buildTools = "perl":buildTools }
37 | pname == "haskeline" = deriv { buildDepends = "utf8String":buildDepends }
38 | pname == "haskell-src" = deriv { buildTools = "happy":buildTools }
39 | pname == "haskell-src-meta" = deriv { buildDepends = "uniplate":buildDepends }
40 | pname == "hflags" = deriv { metaSection = metaSection { license = Unknown (Just "Apache-2.0") } }
41 | pname == "HFuse" = deriv { phaseOverrides = hfusePreConfigure }
42 | pname == "highlighting-kate"= highlightingKatePostProcessing deriv
43 | pname == "HList" = deriv { buildTools = "diffutils":buildTools }
44 | pname == "hmatrix" = deriv { extraLibs = "gsl":"liblapack":"blas":extraLibs }
45 | pname == "hoogle" = deriv { testTarget = "--test-option=--no-net" }
46 | pname == "hspec" = deriv { doCheck = False }
47 | pname == "idris" = deriv { buildTools = "happy":buildTools, extraLibs = "gmp":"boehmgc":extraLibs }
48 | pname == "language-c-quote" = deriv { buildTools = "alex":"happy":buildTools }
49 | pname == "language-java" = deriv { buildDepends = "syb":buildDepends }
50 | pname == "leksah-server" = deriv { buildDepends = "process-leksah":buildDepends }
51 | pname == "lhs2tex" = deriv { extraLibs = "texLive":extraLibs, phaseOverrides = lhs2texPostInstall }
52 | pname == "libffi" = deriv { extraLibs = delete "ffi" extraLibs }
53 | pname == "llvm-base" = deriv { extraLibs = "llvm":extraLibs }
54 | pname == "llvm-general" = deriv { doCheck = False }
55 | pname == "llvm-general-pure"= deriv { doCheck = False }
56 | pname == "markdown-unlit" = deriv { runHaddock = True, phaseOverrides = markdownUnlitNoHaddock }
57 | pname == "multiarg" = deriv { buildDepends = "utf8String":buildDepends }
58 | pname == "ncurses" = deriv { phaseOverrides = ncursesPatchPhase }
59 | pname == "OpenAL" = deriv { extraLibs = "openal":extraLibs }
60 | pname == "OpenGL" = deriv { extraLibs = "mesa":"libX11":extraLibs }
61 | pname == "pandoc" = deriv { buildDepends = "alex":"happy":buildDepends }
62 | pname == "pango" = deriv { extraLibs = "pkgconfig":"libc":extraLibs }
63 | pname == "pcap" = deriv { extraLibs = "libpcap":extraLibs }
64 | pname == "persistent" = deriv { extraLibs = "sqlite3":extraLibs }
65 | pname == "repa-algorithms" = deriv { extraLibs = "llvm":extraLibs }
66 | pname == "repa-examples" = deriv { extraLibs = "llvm":extraLibs }
67 | pname == "SDL-image" = deriv { extraLibs = "SDL_image":extraLibs }
68 | pname == "SDL-mixer" = deriv { extraLibs = "SDL_mixer":extraLibs }
69 | pname == "SDL-ttf" = deriv { extraLibs = "SDL_ttf":extraLibs }
70 | pname == "svgcairo" = deriv { extraLibs = "libc":extraLibs }
71 | pname == "terminfo" = deriv { extraLibs = "ncurses":extraLibs }
72 | pname == "threadscope" = deriv { configureFlags = "--ghc-options=-rtsopts":configureFlags }
73 | pname == "trifecta" = deriv { phaseOverrides = trifectaPostPatch }
74 | pname == "vacuum" = deriv { extraLibs = "ghcPaths":extraLibs }
75 | pname == "wxc" = deriv { extraLibs = "wxGTK":"mesa":"libX11":extraLibs, phaseOverrides = wxcPostInstall }
76 | pname == "wxcore" = deriv { extraLibs = "wxGTK":"mesa":"libX11":extraLibs }
77 | pname == "X11" && version >= Version [1,6] []
78 = deriv { extraLibs = "libXinerama":"libXext":"libXrender":extraLibs }
79 | pname == "X11" = deriv { extraLibs = "libXinerama":"libXext":extraLibs }
80 | pname == "X11-xft" = deriv { extraLibs = "pkgconfig":"freetype":"fontconfig":extraLibs
81 , configureFlags = "--extra-include-dirs=${freetype}/include/freetype2":configureFlags
83 | pname == "xmonad" = deriv { phaseOverrides = xmonadPostInstall }
86cudaConfigurePhase :: String
87cudaConfigurePhase = unlines
88 [ "# Perhaps this should be the default in cabal.nix ..."
90 , "# The cudatoolkit provides both 64 and 32-bit versions of the"
91 , "# library. GHC's linker fails if the wrong version is found first."
92 , "# We solve this by eliminating lib64 from the path on 32-bit"
93 , "# platforms and putting lib64 first on 64-bit platforms."
94 , "libPaths = if self.stdenv.is64bit then \"lib64 lib\" else \"lib\";"
95 , "configurePhase = ''"
96 , " for i in Setup.hs Setup.lhs; do"
97 , " test -f $i && ghc --make $i"
99 , " for p in $extraBuildInputs $propagatedNativeBuildInputs; do"
100 , " if [ -d \"$p/include\" ]; then"
101 , " extraLibDirs=\"$extraLibDirs --extra-include-dir=$p/include\""
103 , " for d in $libPaths; do"
104 , " if [ -d \"$p/$d\" ]; then"
105 , " extraLibDirs=\"$extraLibDirs --extra-lib-dir=$p/$d\""
109 , " ./Setup configure --verbose --prefix=\"$out\" $libraryProfiling $extraLibDirs $configureFlags"
113ghcModPostInstall :: String
114ghcModPostInstall = unlines
116 , " cd $out/share/$pname-$version"
120 , " ensureDir \"$out/share/emacs\""
121 , " mv $pname-$version emacs/site-lisp"
122 , " mv $out/bin/ghc-mod $out/bin/.ghc-mod-wrapped"
123 , " cat - > $out/bin/ghc-mod <<EOF"
124 , " #! ${self.stdenv.shell}"
127 , " eval exec $out/bin/.ghc-mod-wrapped \\$COMMAND \\$( ${self.ghc.GHCGetPackages} ${self.ghc.version} | tr \" \" \"\\n\" | tail -n +2 | paste -d \" \" - - | sed 's/.*/-g \"&\"/' | tr \"\\n\" \" \") \"\\$@\""
129 , " chmod +x $out/bin/ghc-mod"
133wxcPostInstall :: String
134wxcPostInstall = unlines
136 , " cp -v dist/build/libwxc.so.${self.version} $out/lib/libwxc.so"
140cabalInstallPostInstall :: String
141cabalInstallPostInstall = unlines
144 , " mv bash-completion $out/etc/bash_completion.d"
148darcsInstallPostInstall :: String
149darcsInstallPostInstall = unlines
151 , " mkdir -p $out/etc/bash_completion.d"
152 , " mv contrib/darcs_completion $out/etc/bash_completion.d/darcs"
156highlightingKatePostProcessing :: Derivation -> Derivation
157highlightingKatePostProcessing deriv@(MkDerivation {..}) = deriv
158 { phaseOverrides = "prePatch = \"sed -i -e 's|regex-pcre-builtin|regex-pcre|' highlighting-kate.cabal\";"
159 , buildDepends = "regex-pcre" : filter (/="regex-pcre-builtin") buildDepends
162xmonadPostInstall :: String
163xmonadPostInstall = unlines
165 , " mkdir -p $out/share/man/man1"
166 , " mv $out/share/xmonad-*/man/*.1 $out/share/man/man1/"
170gitAnnexOverrides :: String
171gitAnnexOverrides = unlines
172 [ "installPhase = ''"
173 , " export HOME=\"$NIX_BUILD_TOP/tmp\""
178 , " cp dist/build/git-annex/git-annex git-annex"
179 , " ./git-annex test"
183ghciPostInstall :: String
184ghciPostInstall = unlines
186 , " ensureDir \"$out/share/ghci\""
187 , " ln -s \"$out/share/$pname-$version/ghci\" \"$out/share/ghci/$pname\""
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 , " sed -i -e \"s/LANGUAGE FlexibleContexts/LANGUAGE FlexibleContexts, RankNTypes/\" System/Fuse.hsc"
196 , " sed -i -e \"s/E(Exception/E(catch, Exception, IOException/\" System/Fuse.hsc"
197 , " sed -i -e \"s/IO(catch,/IO(/\" System/Fuse.hsc"
198 , " sed -i -e \"s/IO.catch/ E.catch/\" System/Fuse.hsc"
199 , " sed -i -e \"s/const exitFailure/\\\\\\\\(_ :: IOException) -> exitFailure/\" System/Fuse.hsc"
203ghcPathsPatches :: String
204ghcPathsPatches = "patches = [ ./ghc-paths-nix.patch ];"
206lhs2texPostInstall :: String
207lhs2texPostInstall = unlines
209 , " mkdir -p \"$out/share/doc/$name\""
210 , " cp doc/Guide2.pdf $out/share/doc/$name"
211 , " mkdir -p \"$out/nix-support\""
215ncursesPatchPhase :: String
216ncursesPatchPhase = "patchPhase = \"find . -type f -exec sed -i -e 's|ncursesw/||' {} \\\\;\";"
218trifectaPostPatch :: String
219trifectaPostPatch = unlines
221 , " substituteInPlace trifecta.cabal \\"
222 , " --replace \"blaze-html >= 0.5 && < 0.6,\" \"blaze-html >= 0.5 && < 0.7,\" \\"
223 , " --replace \"hashable >= 1.2 && < 1.3,\" \"hashable >= 1.1 && < 1.3,\" \\"
224 , " --replace \"fingertree >= 0.0.1 && < 0.1,\" \"fingertree >= 0.0.1 && < 0.2,\" \\"
225 , " --replace \"comonad == 3.*,\" \"comonad >= 3 && < 5,\" \\"
226 , " --replace \"comonad >= 3 && < 4,\" \"comonad >= 3 && < 5,\""
230doctestNoHaddock, markdownUnlitNoHaddock :: String
231markdownUnlitNoHaddock = "noHaddock = self.stdenv.lib.versionOlder self.ghc.version \"7.4\";"
232doctestNoHaddock = markdownUnlitNoHaddock
234cabal2nixDoCheckHook :: String
235cabal2nixDoCheckHook = "doCheck = self.stdenv.lib.versionOlder \"7.6\" self.ghc.version;"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list