git.iko.soy/typeable/cabal2nix
on master help sign in
Added a few post-processing steps.
commit12b702184fe1b7de5cfb18fd6f322570c2b62bca authorAndres Loeh <mail@andres-loeh.de> dateSun 20 May 2012, 14:06 (14 years ago) parent3fda2c0
3 files changed+40−7
src/Cabal2Nix/Generate.hs+1−1 src/Cabal2Nix/PostProcess.hs+35−2 src/Distribution/NixOS/Derivation/Cabal.hs+4−4
src/Cabal2Nix/Generate.hs+1−1
@@ -27,7 +27,7 @@ cabal2nix cabal = normalize $ postProcess MkDerivation
2727 , configureFlags = []
2828 , cabalFlags = configureCabalFlags pkg
2929 , runHaddock = True
30− , postInstall = ""
30+ , phaseOverrides = ""
3131 , metaSection = Meta
3232 { homepage = Cabal.homepage descr
3333 , description = Cabal.synopsis descr
src/Cabal2Nix/PostProcess.hs+35−2
@@ -9,9 +9,10 @@ postProcess :: Derivation -> Derivation
99postProcess deriv@(MkDerivation {..})
1010 | pname == "alex" = deriv { buildTools = "perl":buildTools }
1111 | pname == "cairo" = deriv { extraLibs = "pkgconfig":"libc":"cairo":"zlib":extraLibs }
12+ | pname == "cuda" = deriv { phaseOverrides = cudaConfigurePhase, extraLibs = "cudatoolkit":"nvidia_x11":"self.stdenv.gcc":extraLibs }
1213 | pname == "editline" = deriv { extraLibs = "libedit":extraLibs }
1314 | pname == "epic" = deriv { extraLibs = "gmp":"boehmgc":extraLibs, buildTools = "happy":buildTools }
14− | pname == "ghc-mod" = deriv { postInstall = ghcModPostInstall, buildTools = "emacs":buildTools }
15+ | pname == "ghc-mod" = deriv { phaseOverrides = ghcModPostInstall, buildTools = "emacs":buildTools }
1516 | pname == "glade" = deriv { extraLibs = "pkgconfig":"libc":extraLibs, pkgConfDeps = "gtkC":delete "gtk" pkgConfDeps }
1617 | pname == "glib" = deriv { extraLibs = "pkgconfig":"libc":extraLibs }
1718 | pname == "GLUT" = deriv { extraLibs = "glut":"libSM":"libICE":"libXmu":"libXi":"mesa":extraLibs }
@@ -23,6 +24,7 @@ postProcess deriv@(MkDerivation {..})
2324 | pname == "haskell-src-meta" = deriv { buildDepends = "uniplate":buildDepends }
2425 | pname == "hmatrix" = deriv { extraLibs = "gsl":"liblapack":"blas":extraLibs }
2526 | pname == "idris" = deriv { buildTools = "happy":buildTools }
27+ | pname == "language-c-quote" = deriv { buildTools = "alex":"happy":buildTools }
2628 | pname == "leksah-server" = deriv { buildDepends = "process-leksah":buildDepends }
2729 | pname == "multiarg" = deriv { buildDepends = "utf8String":buildDepends }
2830 | pname == "OpenAL" = deriv { extraLibs = "openal":extraLibs }
@@ -39,7 +41,7 @@ postProcess deriv@(MkDerivation {..})
3941 | pname == "threadscope" = deriv { configureFlags = "--ghc-options=-rtsopts":configureFlags }
4042 | pname == "vacuum" = deriv { extraLibs = "ghcPaths":extraLibs }
4143 | pname == "wxcore" = deriv { extraLibs = "wxGTK":"mesa":"libX11":extraLibs }
42− | pname == "wxc" = deriv { extraLibs = "wxGTK":"mesa":"libX11":extraLibs, postInstall = wxcPostInstall }
44+ | pname == "wxc" = deriv { extraLibs = "wxGTK":"mesa":"libX11":extraLibs, phaseOverrides = wxcPostInstall }
4345 | pname == "X11" && version >= (Version [1,6] [])
4446 = deriv { extraLibs = "libXinerama":"libXext":"libXrender":extraLibs }
4547 | pname == "X11" = deriv { extraLibs = "libXinerama":"libXext":extraLibs }
@@ -48,6 +50,37 @@ postProcess deriv@(MkDerivation {..})
4850 }
4951 | otherwise = deriv
5052
53+cudaConfigurePhase :: String
54+cudaConfigurePhase = unlines
55+ [ "# Perhaps this should be the default in cabal.nix ..."
56+ , "#"
57+ , "# The cudatoolkit provides both 64 and 32-bit versions of the"
58+ , "# library. GHC's linker fails if the wrong version is found first."
59+ , "# We solve this by eliminating lib64 from the path on 32-bit"
60+ , "# platforms and putting lib64 first on 64-bit platforms."
61+ , ""
62+ , "libPaths = if self.stdenv.is64bit then \"lib64 lib\" else \"lib\";"
63+ , ""
64+ , "configurePhase = ''"
65+ , " for i in Setup.hs Setup.lhs; do"
66+ , " test -f $i && ghc --make $i"
67+ , " done"
68+ , ""
69+ , " for p in $extraBuildInputs $propagatedBuildNativeInputs; do"
70+ , " if [ -d \"$p/include\" ]; then"
71+ , " extraLibDirs=\"$extraLibDirs --extra-include-dir=$p/include\""
72+ , " fi"
73+ , " for d in $libPaths; do"
74+ , " if [ -d \"$p/$d\" ]; then"
75+ , " extraLibDirs=\"$extraLibDirs --extra-lib-dir=$p/$d\""
76+ , " fi"
77+ , " done"
78+ , " done"
79+ , ""
80+ , " ./Setup configure --verbose --prefix=\"$out\" $libraryProfiling $extraLibDirs $configureFlags"
81+ , "'';"
82+ ]
83+
5184ghcModPostInstall :: String
5285ghcModPostInstall = unlines
5386 [ "postInstall = ''"
src/Distribution/NixOS/Derivation/Cabal.hs+4−4
@@ -53,7 +53,7 @@ data Derivation = MkDerivation
5353 , configureFlags :: [String]
5454 , cabalFlags :: FlagAssignment
5555 , runHaddock :: Bool
56− , postInstall :: String
56+ , phaseOverrides :: String
5757 , metaSection :: Meta
5858 }
5959 deriving (Show, Eq, Ord)
@@ -81,14 +81,14 @@ renderDerivation deriv = funargs (map text ("cabal" : inputs)) $$ vcat
8181 , listattr "pkgconfigDepends" (pkgConfDeps deriv)
8282 , onlyIf renderedFlags $ attr "configureFlags" $ doubleQuotes (sep renderedFlags)
8383 , boolattr "noHaddock" (not (runHaddock deriv)) (not (runHaddock deriv))
84− , onlyIf (postInstall deriv) $ text (postInstall deriv)
84+ , onlyIf (phaseOverrides deriv) $ vcat ((map text . lines) (phaseOverrides deriv))
8585 , disp (metaSection deriv)
8686 ]
8787 , rbrace <> rparen
8888 , text ""
8989 ]
9090 where
91− inputs = nub $ sortBy (compare `on` map toLower) $ filter (/="cabal") $
91+ inputs = nub $ sortBy (compare `on` map toLower) $ filter (/="cabal") $ filter (not . isPrefixOf "self.") $
9292 buildDepends deriv ++ buildTools deriv ++ extraLibs deriv ++ pkgConfDeps deriv
9393 renderedFlags = [ text "-f" <> (if enable then empty else char '-') <> text f | (FlagName f, enable) <- cabalFlags deriv ]
9494 ++ map text (configureFlags deriv)
@@ -121,7 +121,7 @@ parseDerivation buf
121121 , cabalFlags = []
122122 , runHaddock = case noHaddock of "true":[] -> False
123123 _ -> True
124− , postInstall = ""
124+ , phaseOverrides = ""
125125 , metaSection = Meta
126126 { homepage = ""
127127 , description = ""