cabal2nix 1.54 → 1.55
raw patch · 8 files changed
+56/−14 lines, 8 files
Files
- cabal2nix.cabal +3/−3
- src/Cabal2Nix/Flags.hs +0/−1
- src/Cabal2Nix/Generate.hs +1/−0
- src/Cabal2Nix/Hackage.hs +9/−1
- src/Cabal2Nix/Name.hs +3/−0
- src/Cabal2Nix/PostProcess.hs +31/−5
- src/Distribution/NixOS/Derivation/Cabal.hs +3/−0
- src/cabal2nix.hs +6/−4
cabal2nix.cabal view
@@ -1,5 +1,5 @@ Name: cabal2nix-Version: 1.54+Version: 1.55 Copyright: Peter Simons, Andres Loeh License: BSD3 License-File: LICENSE@@ -34,8 +34,8 @@ . The only required argument is the path to the cabal file. For example: .- > cabal2nix http://hackage.haskell.org/packages/archive/cabal2nix/1.54/cabal2nix.cabal- > cabal2nix cabal://cabal2nix-1.54+ > cabal2nix http://hackage.haskell.org/packages/archive/cabal2nix/1.55/cabal2nix.cabal+ > cabal2nix cabal://cabal2nix-1.55 . If the @--sha256@ option has not been specified, cabal2nix calls @nix-prefetch-url@ to determine the hash automatically. This causes
src/Cabal2Nix/Flags.hs view
@@ -6,7 +6,6 @@ configureCabalFlags :: PackageIdentifier -> FlagAssignment configureCabalFlags (PackageIdentifier (PackageName name) _) | name == "accelerate-examples"= [disable "opencl"]- | name == "pandoc" = [enable "blaze_html_0_5"] | name == "git-annex" = [ enable "S3", enable "WebDAV", enable "Inotify" , enable "Dbus", enable "Assistant", enable "Webapp" , enable "Pairing", enable "XMPP", enable "DNS"
src/Cabal2Nix/Generate.hs view
@@ -30,6 +30,7 @@ , runHaddock = True , jailbreak = False , doCheck = True+ , testTarget = "" , phaseOverrides = "" , metaSection = Meta { homepage = Cabal.homepage descr
src/Cabal2Nix/Hackage.hs view
@@ -11,6 +11,7 @@ import System.Directory ( doesFileExist, getHomeDirectory, createDirectoryIfMissing ) import System.FilePath ( dropFileName, (</>), (<.>) ) import System.Process ( readProcess )+import Control.Exception (handle, SomeException(..)) import qualified Distribution.Hackage.DB as DB @@ -35,12 +36,19 @@ exists <- doesFileExist cachePath hash' <- if exists then readFile cachePath- else readProcess "bash" ["-c", "exec nix-prefetch-url 2>/dev/tty " ++ hackagePath pkg TarGz] ""+ else getHackageHash let hash = reverse (dropWhile (=='\n') (reverse hash')) unless exists $ do createDirectoryIfMissing True (dropFileName cachePath) writeFile cachePath hash return hash+ where getHackageHash = do+ let command = "exec nix-prefetch-url 2>/dev/tty " ++ hackagePath pkg TarGz+ handle handlePrefetchError (readProcess "bash" ["-c", command] "")+ handlePrefetchError (SomeException _) = do+ error $ "\nError: Cannot compute hash. (Not a hackage project?)\n" +++ "Specify hash explicitly via --sha256 and add appropriate \"src\" attribute " +++ "to resulting nix expression." hashCachePath :: PackageIdentifier -> IO FilePath hashCachePath (PackageIdentifier (PackageName name) version') = do
src/Cabal2Nix/Name.hs view
@@ -53,9 +53,12 @@ libNixName "libglade-2.0" = return "libglade" libNixName "libgsasl" = return "gsasl" libNixName "librsvg-2.0" = return "librsvg"+libNixName "libusb-1.0" = return "libusb" libNixName "libxml-2.0" = return "libxml2" libNixName "libzip" = return "libzip" libNixName "m" = [] -- in stdenv+libNixName "ncursesw" = return "ncurses"+libNixName "panelw" = return "ncurses" libNixName "pangocairo" = return "pango" libNixName "pcre" = return "pcre" libNixName "png" = return "libpng"
src/Cabal2Nix/PostProcess.hs view
@@ -13,13 +13,15 @@ | pname == "cairo" = deriv { extraLibs = "pkgconfig":"libc":"cairo":"zlib":extraLibs } | pname == "cuda" = deriv { phaseOverrides = cudaConfigurePhase, extraLibs = "cudatoolkit":"nvidia_x11":"self.stdenv.gcc":extraLibs } | pname == "darcs" = deriv { phaseOverrides = darcsInstallPostInstall }+ | pname == "dns" = deriv { testTarget = "spec" } | pname == "editline" = deriv { extraLibs = "libedit":extraLibs } | pname == "epic" = deriv { extraLibs = "gmp":"boehmgc":extraLibs, buildTools = "happy":buildTools } | pname == "ghc-heap-view" = deriv { phaseOverrides = ghciPostInstall } | pname == "ghc-mod" = deriv { phaseOverrides = ghcModPostInstall, buildTools = "emacs":buildTools } | pname == "ghc-paths" = deriv { phaseOverrides = ghcPathsPatches } | pname == "ghc-vis" = deriv { phaseOverrides = ghciPostInstall }- | pname == "git-annex" = deriv { phaseOverrides = gitAnnexOverrides, buildTools = "git":"rsync":"gnupg1":"curl":"lsof":"openssh":"which":"bup":buildTools }+ | pname == "git-annex" = deriv { phaseOverrides = gitAnnexOverrides, buildTools = "git":"rsync":"gnupg1":"curl":"lsof":"openssh":"which":"bup":"perl":buildTools }+ | pname == "github-backup" = deriv { buildTools = "git":buildTools } | pname == "glade" = deriv { extraLibs = "pkgconfig":"libc":extraLibs, pkgConfDeps = "gtkC":delete "gtk" pkgConfDeps } | pname == "glib" = deriv { extraLibs = "pkgconfig":"libc":extraLibs } | pname == "GLUT" = deriv { extraLibs = "glut":"libSM":"libICE":"libXmu":"libXi":"mesa":extraLibs }@@ -35,18 +37,20 @@ | pname == "highlighting-kate"= highlightingKatePostProcessing deriv | pname == "hmatrix" = deriv { extraLibs = "gsl":"liblapack":"blas":extraLibs } | pname == "hspec" = deriv { doCheck = False }- | pname == "idris" = if version < Version [0,9,9] []- then deriv { buildTools = "happy":buildTools, extraLibs = "gmp":extraLibs }- else deriv { buildTools = "happy":buildTools, extraLibs = "gmp":"boehmgc":extraLibs }+ | pname == "idris" = deriv { buildTools = "happy":buildTools, extraLibs = "gmp":"boehmgc":extraLibs } | pname == "language-c-quote" = deriv { buildTools = "alex":"happy":buildTools } | pname == "language-java" = deriv { buildDepends = "syb":buildDepends } | pname == "leksah-server" = deriv { buildDepends = "process-leksah":buildDepends } | pname == "lhs2tex" = deriv { extraLibs = "texLive":extraLibs, phaseOverrides = lhs2texPostInstall } | pname == "libffi" = deriv { extraLibs = delete "ffi" extraLibs } | pname == "llvm-base" = deriv { extraLibs = "llvm":extraLibs }+ | pname == "llvm-general" = deriv { doCheck = False }+ | pname == "llvm-general-pure"= deriv { doCheck = False } | pname == "multiarg" = deriv { buildDepends = "utf8String":buildDepends }+ | pname == "ncurses" = deriv { phaseOverrides = ncursesPatchPhase } | pname == "OpenAL" = deriv { extraLibs = "openal":extraLibs } | pname == "OpenGL" = deriv { extraLibs = "mesa":"libX11":extraLibs }+ | pname == "pandoc" = deriv { buildDepends = "alex":"happy":buildDepends } | pname == "pango" = deriv { extraLibs = "pkgconfig":"libc":extraLibs } | pname == "pcap" = deriv { extraLibs = "libpcap":extraLibs } | pname == "persistent" = deriv { extraLibs = "sqlite3":extraLibs }@@ -58,6 +62,7 @@ | pname == "svgcairo" = deriv { extraLibs = "libc":extraLibs } | pname == "terminfo" = deriv { extraLibs = "ncurses":extraLibs } | pname == "threadscope" = deriv { configureFlags = "--ghc-options=-rtsopts":configureFlags }+ | pname == "trifecta" = deriv { phaseOverrides = trifectaPostPatch } | pname == "vacuum" = deriv { extraLibs = "ghcPaths":extraLibs } | pname == "wxc" = deriv { extraLibs = "wxGTK":"mesa":"libX11":extraLibs, phaseOverrides = wxcPostInstall } | pname == "wxcore" = deriv { extraLibs = "wxGTK":"mesa":"libX11":extraLibs }@@ -106,6 +111,14 @@ , " cd .." , " ensureDir \"$out/share/emacs\"" , " mv $pname-$version emacs/site-lisp"+ , " mv $out/bin/ghc-mod $out/ghc-mod"+ , " cat - > $out/bin/ghc-mod <<EOF"+ , " #!/bin/sh"+ , " COMMAND=\\$1"+ , " shift"+ , " eval exec $out/ghc-mod \\$COMMAND \\$( ${self.ghc.GHCGetPackages} ${self.ghc.ghcVersion} | tr \" \" \"\\n\" | tail -n +2 | paste -d \" \" - - | sed 's/.*/-g \"&\"/' | tr \"\\n\" \" \") \"\\$@\""+ , " EOF"+ , " chmod +x $out/bin/ghc-mod" , "'';" ] @@ -149,7 +162,7 @@ gitAnnexOverrides :: String gitAnnexOverrides = unlines [ "preConfigure = \"patchShebangs .\";"- , "installPhase = \"make PREFIX=$out CABAL=./Setup docs install\";"+ , "installPhase = \"./Setup install\";" , "checkPhase = ''" , " export HOME=\"$NIX_BUILD_TOP/tmp\"" , " mkdir \"$HOME\""@@ -187,5 +200,18 @@ , " mkdir -p \"$out/share/doc/$name\"" , " cp doc/Guide2.pdf $out/share/doc/$name" , " mkdir -p \"$out/nix-support\""+ , "'';"+ ]++ncursesPatchPhase :: String+ncursesPatchPhase = "patchPhase = \"find . -type f -exec sed -i -e 's|ncursesw/||' {} \\\\;\";"++trifectaPostPatch :: String+trifectaPostPatch = unlines+ [ "postPatch = ''"+ , " substituteInPlace trifecta.cabal \\"+ , " --replace \"blaze-html >= 0.5 && < 0.6,\" \"blaze-html >= 0.5 && < 0.7,\" \\"+ , " --replace \"hashable >= 1.2 && < 1.3,\" \"hashable >= 1.1 && < 1.3,\" \\"+ , " --replace \"fingertree >= 0.0.1 && < 0.1,\" \"fingertree >= 0.0.1 && < 0.2,\"" , "'';" ]
src/Distribution/NixOS/Derivation/Cabal.hs view
@@ -56,6 +56,7 @@ , runHaddock :: Bool , jailbreak :: Bool , doCheck :: Bool+ , testTarget :: String , phaseOverrides :: String , metaSection :: Meta }@@ -87,6 +88,7 @@ , boolattr "noHaddock" (not (runHaddock deriv)) (not (runHaddock deriv)) , boolattr "jailbreak" (jailbreak deriv) (jailbreak deriv) , boolattr "doCheck" (not (doCheck deriv)) (doCheck deriv)+ , onlyIf (testTarget deriv) $ attr "testTarget" $ string (testTarget deriv) , onlyIf (phaseOverrides deriv) $ vcat ((map text . lines) (phaseOverrides deriv)) , disp (metaSection deriv) ]@@ -131,6 +133,7 @@ , runHaddock = noHaddock /= ["true"] , jailbreak = jailBreak == ["true"] , doCheck = docheck == ["true"] || null docheck+ , testTarget = "" , phaseOverrides = "" , metaSection = Meta { homepage = ""
src/cabal2nix.hs view
@@ -18,7 +18,7 @@ data Configuration = Configuration { optPrintHelp :: Bool , optPrintVersion :: Bool- , optSha256 :: String+ , optSha256 :: Maybe String , optMaintainer :: [String] , optPlatform :: [String] , optHaddock :: Bool@@ -31,7 +31,7 @@ defaultConfiguration = Configuration { optPrintHelp = False , optPrintVersion = False- , optSha256 = ""+ , optSha256 = Nothing , optMaintainer = [] , optPlatform = [] , optHaddock = True@@ -42,7 +42,7 @@ options :: [OptDescr (Configuration -> Configuration)] options = [ Option "h" ["help"] (NoArg (\o -> o { optPrintHelp = True })) "show this help text"- , Option "" ["sha256"] (ReqArg (\x o -> o { optSha256 = x }) "HASH") "sha256 hash of source tarball"+ , Option "" ["sha256"] (ReqArg (\x o -> o { optSha256 = Just x }) "HASH") "sha256 hash of source tarball" , Option "m" ["maintainer"] (ReqArg (\x o -> o { optMaintainer = x : optMaintainer o }) "MAINTAINER") "maintainer of this package (may be specified multiple times)" , Option "p" ["platform"] (ReqArg (\x o -> o { optPlatform = x : optPlatform o }) "PLATFORM") "supported build platforms (may be specified multiple times)" , Option "" ["no-haddock"] (NoArg (\o -> o { optHaddock = False })) "don't run Haddock when building this package"@@ -84,7 +84,9 @@ exitFailure let packageId = package (packageDescription cabal)- sha <- if null (optSha256 cfg) then hashPackage packageId else return (optSha256 cfg)+ sha <- case optSha256 cfg of+ Just hash -> return hash+ Nothing -> hashPackage packageId let deriv = (cabal2nix cabal) { sha256 = sha, runHaddock = optHaddock cfg, jailbreak = optJailbreak cfg } deriv' = deriv { metaSection = (metaSection deriv)