packages feed

cabal2nix 2.1 → 2.1.1

raw patch · 5 files changed

+132/−92 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

+ README.md view
@@ -0,0 +1,84 @@+Cabal2nix+=========++`cabal2nix` converts a single Cabal file into a single Nix build expression.+For example:++    $ cabal2nix cabal://mtl+    { mkDerivation, base, stdenv, transformers }:+    mkDerivation {+      pname = "mtl";+      version = "2.2.1";+      sha256 = "1icdbj2rshzn0m1zz5wa7v3xvkf6qw811p4s7jgqwvx1ydwrvrfa";+      buildDepends = [ base transformers ];+      homepage = "http://github.com/ekmett/mtl";+      description = "Monad classes, using functional dependencies";+      license = stdenv.lib.licenses.bsd3;+    }+++Cabal files can be referred to using the magic URL `cabal://NAME-VERSION`,+which will automatically download the file from Hackage. Alternatively, a+direct `http://host/path/pkg.cabal` URL can be provided, as well as a+`file:///local/path/pkg.cabal` URI that doesn't depend on network access.+However, if the source hash is not already in `cabal2nix`'s cache or provided+using the `--sha256` option, `cabal2nix` still needs to download the source+code to compute the hash, which obviously still causes network traffic. Run the+utility with `--help` to see the complete list of supported command line flags.++Detailed instructions how to use those generated files with Nix can be found at+http://nixos.org/nixpkgs/manual/#users-guide-to-the-haskell-infrastructure.++`cabal2nix` can also build derivations for projects from other sources than+hackage. You only need to provide an URI that points to a cabal project. The+most common usecase for this is probably to generate a derivation for a project+on the local file system:++    $ cabal get mtl-2.2.1 && cd mtl-2.2.1+    $ cabal2nix .+    { mkDerivation, base, stdenv, transformers }:+    mkDerivation {+      pname = "mtl";+      version = "2.2.1";+      src = ./.;+      buildDepends = [ base transformers ];+      homepage = "http://github.com/ekmett/mtl";+      description = "Monad classes, using functional dependencies";+      license = stdenv.lib.licenses.bsd3;+    }++This derivation will not fetch from hackage, but instead use the directory which+contains the derivation as the source repository.++`cabal2nix` currently supports the following respository types:++* directory+* source archive (zip, tar.gz, ...) from http or https URL or local file.+* git, mercurial, svn or bazaar repository++How to compile this package+---------------------------++The `cabal2nix.cabal` file for this package is automatically generated by the+`generate-cabal-file.hs` program. The easiest way to accomplish that is to run++    nix-shell release.nix -A cabal2nix.ghc7102.x86_64-linux.env --run "runhaskell generate-cabal-file.hs >cabal2nix.cabal"++where `x86_64-linux` should be replaced with whatever system ID is appropriate+for your local machine. Basically, `generate-cabal-file.hs` requires the+[cartel](http://hackage.haskell.org/package/cartel) library and `git` to run.++With the Cabal file in place, this is a normal Haskell project that can be+compiled with `cabal-install`.++Users of Nix can build this package by running++    nix-build release.nix -A cabal2nix.ghc7102.x86_64-linux++where, again, `x86_64-linux` should be replaced with the appropriate value.+This gives you an executable at `result/bin/cabal2nix`. If you'd like to+install the latest release version, then++    nix-env -f "<nixpkgs>" -iA cabal2nix++is the way to go.
cabal2nix.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           cabal2nix-version:        2.1+version:        2.1.1 synopsis:       Convert Cabal files into Nix build instructions. description:    Convert Cabal files into Nix build instructions. Users of Nix can install the latest version by running:                 .@@ -60,6 +60,9 @@ tested-with:    GHC > 7.10 && < 8.1 build-type:     Simple cabal-version:  >= 1.10++extra-source-files:+    README.md  source-repository head   type: git
src/Distribution/Nixpkgs/Haskell/FromCabal.hs view
@@ -40,7 +40,7 @@       -- We have to call the Cabal finalizer several times with different resolver       -- functions, and this convenience function makes our code shorter.       finalize :: HaskellResolver -> Either [Dependency] (PackageDescription,FlagAssignment)-      finalize resolver = finalizePackageDescription flags resolver arch compiler constraints (enableTests genDesc)+      finalize resolver = finalizePackageDescription flags resolver arch compiler constraints (enableBenchmarks (enableTests genDesc))        descr :: PackageDescription; missingDeps :: [Dependency]       (descr,missingDeps) = case finalize jailbrokenResolver of@@ -132,3 +132,12 @@      enableTest :: TestSuite -> TestSuite     enableTest t = t { testEnabled = True }++enableBenchmarks :: GenericPackageDescription -> GenericPackageDescription+enableBenchmarks gd = gd { condBenchmarks = flaggedBenchmarks }+  where+    flaggedBenchmarks :: [(String, CondTree ConfVar [Dependency] Benchmark)]+    flaggedBenchmarks = map (second (mapTreeData enableBenchmark)) (condBenchmarks gd)++    enableBenchmark :: Benchmark -> Benchmark+    enableBenchmark t = t { benchmarkEnabled = True }
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs view
@@ -57,15 +57,15 @@ libNixName "gnome-vfs-module-2.0"               = return "gnome_vfs_module" libNixName "gobject-2.0"                        = return "glib" libNixName "gobject-introspection-1.0"          = return "gobjectIntrospection"-libNixName "gstreamer-audio-0.10"               = return "gst_plugins_base"-libNixName "gstreamer-audio-1.0"                = return "gst_plugins_base"-libNixName "gstreamer-base-0.10"                = return "gst_plugins_base"-libNixName "gstreamer-base-1.0"                 = return "gst_plugins_base"+libNixName "gstreamer-audio-0.10"               = return "gst-plugins-base"+libNixName "gstreamer-audio-1.0"                = return "gst-plugins-base"+libNixName "gstreamer-base-0.10"                = return "gst-plugins-base"+libNixName "gstreamer-base-1.0"                 = return "gst-plugins-base" libNixName "gstreamer-controller-0.10"          = return "gstreamer" libNixName "gstreamer-dataprotocol-0.10"        = return "gstreamer"-libNixName "gstreamer-net-0.10"                 = return "gst_plugins_base"-libNixName "gstreamer-plugins-base-0.10"        = return "gst_plugins_base"-libNixName "gstreamer-video-1.0"                = return "gst_plugins_base"+libNixName "gstreamer-net-0.10"                 = return "gst-plugins-base"+libNixName "gstreamer-plugins-base-0.10"        = return "gst-plugins-base"+libNixName "gstreamer-video-1.0"                = return "gst-plugins-base" libNixName "gthread-2.0"                        = return "glib" libNixName "gtk+-2.0"                           = return "gtk2" libNixName "gtk+-3.0"                           = return "gtk3"@@ -141,10 +141,14 @@ libNixName "wayland-cursor"                     = return "wayland" libNixName "wayland-egl"                        = return "mesa" libNixName "wayland-server"                     = return "wayland"-libNixName "webkit2gtk-4.0"                     = return "webkit2gtk"-libNixName "webkit2gtk-web-extension-4.0"       = return "webkit2gtk-web-extension"-libNixName "webkitgtk"                          = return "webkit"-libNixName "webkitgtk-3.0"                      = return "webkit"+-- These are the old APIs, of which 2.4 is the last provider, so map directly to that+libNixName "javascriptcoregtk-3.0"              = return "webkitgtk24x"+libNixName "webkitgtk-3.0"                      = return "webkitgtk24x"+-- This is the current API, so let it reference an alias for the latest version+libNixName "javascriptcoregtk-4.0"              = return "webkitgtk"+libNixName "webkit2gtk-4.0"                     = return "webkitgtk"+-- This package doesn't actually exist in nixpkgs at present+libNixName "webkit2gtk-web-extension-4.0"       = return "webkitgtk-web-extension" libNixName "X11"                                = return "libX11" libNixName "xau"                                = return "libXau" libNixName "Xcursor"                            = return "libXcursor"
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs view
@@ -3,7 +3,6 @@ module Distribution.Nixpkgs.Haskell.FromCabal.PostProcess ( postProcess ) where  import Control.Lens-import Data.List import Data.List.Split import Data.Set ( Set ) import qualified Data.Set as Set@@ -51,21 +50,14 @@   , ("freenect < 1.2.1", over configureFlags (Set.union (Set.fromList ["--extra-include-dirs=${pkgs.freenect}/include/libfreenect", "--extra-lib-dirs=${pkgs.freenect}/lib"])))   , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)   , ("gi-cairo", giCairoPhaseOverrides)                     -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-gdk", giGdkPhaseOverrides)                         -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-gdkpixbuf", giGdkPixBufPhaseOverrides)             -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-gio", giPhaseOverrides)                            -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-glib", giPhaseOverrides)                           -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-gobject", giPhaseOverrides)                        -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-gst", gstLibOverrides)                             -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-gstaudio", gstLibAudioOverrides)                   -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-gstbase", gstLibAudioOverrides)                    -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-gstvideo", gstLibAudioOverrides)                   -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-gtk", giGtkPhaseOverrides)                         -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-javascriptcore", giJavascriptCorePhaseOverrides)   -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-gst", giGstLibOverrides "gstreamer")               -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-gstaudio", giGstLibOverrides "gst-plugins-base")   -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-gstbase", giGstLibOverrides "gst-plugins-base")    -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-gstvideo", giGstLibOverrides "gst-plugins-base")   -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-javascriptcore < 4.0.0.0", webkitgtk24xHook)       -- https://github.com/haskell-gi/haskell-gi/issues/36   , ("gi-pango", giCairoPhaseOverrides)                     -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-pangocairo", giPangoCairoPhaseOverrides)           -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-webkit2", giWebkit2PhaseOverrides)                 -- https://github.com/haskell-gi/haskell-gi/issues/36-  , ("gi-webkit2webextension", giWebkit2PhaseOverrides)     -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-pangocairo", giCairoPhaseOverrides)                     -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-webkit", webkitgtk24xHook)   -- https://github.com/haskell-gi/haskell-gi/issues/36   , ("gio", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)   , ("git", set doCheck False)          -- https://github.com/vincenthz/hit/issues/33   , ("git-annex", gitAnnexHook)@@ -120,6 +112,8 @@   , ("thyme", set (libraryDepends . tool . contains (bind "self.cpphs")) True) -- required on Darwin   , ("twilio", set doCheck False)         -- attempts to access the network   , ("tz", set phaseOverrides "preConfigure = \"export TZDIR=${pkgs.tzdata}/share/zoneinfo\";")+  , ("webkitgtk3", webkitgtk24xHook)   -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("webkitgtk3-javascriptcore", webkitgtk24xHook)   -- https://github.com/haskell-gi/haskell-gi/issues/36   , ("websockets", set doCheck False)   -- https://github.com/jaspervdj/websockets/issues/104   , ("Win32", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)))   , ("Win32-shortcut", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)))@@ -164,7 +158,7 @@     gitAnnexOverrides = unlines       [ "preConfigure = \"export HOME=$TEMPDIR; patchShebangs .\";"       , "postBuild = \"ln -sf dist/build/git-annex/git-annex git-annex\";"-      , "installPhase = \"make PREFIX=$out CABAL=./Setup BUILDER=./Setup install\";"+      , "installPhase = \"make PREFIX=$out BUILDER=: install\";"       , "checkPhase = \"./git-annex test\";"       , "enableSharedExecutables = false;"       ]@@ -261,52 +255,14 @@   , "'';"   ] -exportGirSearchPath :: [String] -> String-exportGirSearchPath packages =-  "export HASKELL_GI_GIR_SEARCH_PATH="-  ++ intercalate ":" [ "${" ++ package ++ "}/share/gir-1.0" | package <- packages]--giPhaseOverrides :: Derivation -> Derivation-giPhaseOverrides-  = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["gobjectIntrospection.dev"] ++ "'';")-  . set (libraryDepends . pkgconfig . contains (pkg "gobjectIntrospection")) True--giGdkPhaseOverrides :: Derivation -> Derivation-giGdkPhaseOverrides-  = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["gtk3.dev"] ++ "'';")--gstLibOverrides :: Derivation -> Derivation-gstLibOverrides-  = over (libraryDepends . pkgconfig) (replace (pkg "gstreamer") "gstreamer = pkgs.gst_all_1.gstreamer")--gstLibAudioOverrides :: Derivation -> Derivation-gstLibAudioOverrides-  = over (libraryDepends . pkgconfig) (replace (pkg "gst_plugins_base") "gst_plugins_base = pkgs.gst_all_1.gst-plugins-base")-  . set (libraryDepends . system . contains (pkg "gobjectIntrospection")) True--giGdkPixBufPhaseOverrides :: Derivation -> Derivation-giGdkPixBufPhaseOverrides-  = set phaseOverrides (unlines-    [ "preConfigure = ''"-    , "  " ++ exportGirSearchPath ["gobjectIntrospection.dev", "gdk_pixbuf.dev"]-    , "  export GI_TYPELIB_PATH=${gdk_pixbuf.out}/lib/girepository-1.0"-    , "'';"-    ])-  . set (libraryDepends . pkgconfig . contains (pkg "gobjectIntrospection")) True--giGtkPhaseOverrides :: Derivation -> Derivation-giGtkPhaseOverrides-  = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["gtk3.dev"] ++ "'';")--giJavascriptCorePhaseOverrides :: Derivation -> Derivation-giJavascriptCorePhaseOverrides-  = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["webkitgtk"] ++ "'';")-  . set (libraryDepends . pkgconfig . contains (pkg "webkitgtk")) True+-- Replace a binding for <package> to one to pkgs.gst_all_1.<package>+giGstLibOverrides :: String -> Derivation -> Derivation+giGstLibOverrides package+  = over (libraryDepends . pkgconfig) (replace (pkg (ident # package)) (binding # (ident # package, path # ["pkgs","gst_all_1", ident # package])))  giCairoPhaseOverrides :: Derivation -> Derivation-giCairoPhaseOverrides = over phaseOverrides (++'\n':txt)+giCairoPhaseOverrides = over phaseOverrides (++txt)                       . set (libraryDepends . pkgconfig . contains (pkg "cairo")) True-                      . giPhaseOverrides   where     txt = unlines [ "preCompileBuildDriver = ''"                   , "  PKG_CONFIG_PATH+=\":${cairo}/lib/pkgconfig\""@@ -314,26 +270,6 @@                   , "'';"                   ] -giPangoCairoPhaseOverrides :: Derivation -> Derivation-giPangoCairoPhaseOverrides = set phaseOverrides txt-                           . over (libraryDepends . pkgconfig) addPkgs-  where-    addPkgs = Set.union (Set.fromList [ "system-pango = pkgs.pango"-                                      , "system-cairo = pkgs.cairo" ])-            . Set.insert (pkg "gobjectIntrospection")-    gir = [ "system-pango.dev" ]-    txt = unlines [ "preConfigure = ''" ++ exportGirSearchPath gir ++ "'';"-                  , "preCompileBuildDriver = ''"-                  , "  PKG_CONFIG_PATH+=\":${system-pango.dev}/lib/pkgconfig:${system-cairo.dev}/lib/pkgconfig\""-                  , "  setupCompileFlags+=\" $(pkg-config --libs pangocairo cairo-gobject)\""-                  , "'';"-                  ]--giWebkit2PhaseOverrides :: Derivation -> Derivation-giWebkit2PhaseOverrides-  = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["webkitgtk"] ++ "'';")-  . set (libraryDepends . pkgconfig . contains (pkg "webkitgtk")) True- hfseventsOverrides :: Derivation -> Derivation hfseventsOverrides   = set isLibrary True@@ -341,3 +277,7 @@   . set (libraryDepends . tool . contains (bind "pkgs.darwin.apple_sdk.frameworks.CoreServices")) True   . set (libraryDepends . system . contains (bind "pkgs.darwin.apple_sdk.frameworks.Cocoa")) True   . over (libraryDepends . haskell) (Set.union (Set.fromList (map bind ["self.base", "self.cereal", "self.mtl", "self.text", "self.bytestring"])))++webkitgtk24xHook :: Derivation -> Derivation    -- https://github.com/NixOS/cabal2nix/issues/145+webkitgtk24xHook = set (libraryDepends . pkgconfig . contains (pkg "webkitgtk24x")) True+                 . over (libraryDepends . pkgconfig) (Set.filter (\b -> view localName b /= "webkitgtk24x"))