git.iko.soy/typeable/cabal2nix
on master help sign in
Merge pull request #265 from mdorman/fix-gi-gst-modules

Fix and streamline `gobjectIntrospection`-based library handling

commit490c7d583d0b9c36048bf51979a6d61a0cefd170 authorPeter Simons <simons@cryp.to> dateSun 12 Mar 2017, 17:45 (10 years ago) parent3de0b842d278a8
2 files changed+33−88
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs+15−11 src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+18−77
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs+15−11
@@ -57,15 +57,15 @@ libNixName "gnome-vfs-2.0" = return "gnome_vfs"
5757libNixName "gnome-vfs-module-2.0" = return "gnome_vfs_module"
5858libNixName "gobject-2.0" = return "glib"
5959libNixName "gobject-introspection-1.0" = return "gobjectIntrospection"
60−libNixName "gstreamer-audio-0.10" = return "gst_plugins_base"
61−libNixName "gstreamer-audio-1.0" = return "gst_plugins_base"
62−libNixName "gstreamer-base-0.10" = return "gst_plugins_base"
63−libNixName "gstreamer-base-1.0" = return "gst_plugins_base"
60+libNixName "gstreamer-audio-0.10" = return "gst-plugins-base"
61+libNixName "gstreamer-audio-1.0" = return "gst-plugins-base"
62+libNixName "gstreamer-base-0.10" = return "gst-plugins-base"
63+libNixName "gstreamer-base-1.0" = return "gst-plugins-base"
6464libNixName "gstreamer-controller-0.10" = return "gstreamer"
6565libNixName "gstreamer-dataprotocol-0.10" = return "gstreamer"
66−libNixName "gstreamer-net-0.10" = return "gst_plugins_base"
67−libNixName "gstreamer-plugins-base-0.10" = return "gst_plugins_base"
68−libNixName "gstreamer-video-1.0" = return "gst_plugins_base"
66+libNixName "gstreamer-net-0.10" = return "gst-plugins-base"
67+libNixName "gstreamer-plugins-base-0.10" = return "gst-plugins-base"
68+libNixName "gstreamer-video-1.0" = return "gst-plugins-base"
6969libNixName "gthread-2.0" = return "glib"
7070libNixName "gtk+-2.0" = return "gtk2"
7171libNixName "gtk+-3.0" = return "gtk3"
@@ -141,10 +141,14 @@ libNixName "wayland-client" = return "wayland"
141141libNixName "wayland-cursor" = return "wayland"
142142libNixName "wayland-egl" = return "mesa"
143143libNixName "wayland-server" = return "wayland"
144−libNixName "webkit2gtk-4.0" = return "webkit2gtk"
145−libNixName "webkit2gtk-web-extension-4.0" = return "webkit2gtk-web-extension"
146−libNixName "webkitgtk" = return "webkit"
147−libNixName "webkitgtk-3.0" = return "webkit"
144+-- These are the old APIs, of which 2.4 is the last provider, so map directly to that
145+libNixName "javascriptcoregtk-3.0" = return "webkitgtk24x"
146+libNixName "webkitgtk-3.0" = return "webkitgtk24x"
147+-- This is the current API, so let it reference an alias for the latest version
148+libNixName "javascriptcoregtk-4.0" = return "webkitgtk"
149+libNixName "webkit2gtk-4.0" = return "webkitgtk"
150+-- This package doesn't actually exist in nixpkgs at present
151+libNixName "webkit2gtk-web-extension-4.0" = return "webkitgtk-web-extension"
148152libNixName "X11" = return "libX11"
149153libNixName "xau" = return "libXau"
150154libNixName "Xcursor" = return "libXcursor"
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+18−77
@@ -51,21 +51,14 @@ hooks =
5151 , ("freenect < 1.2.1", over configureFlags (Set.union (Set.fromList ["--extra-include-dirs=${pkgs.freenect}/include/libfreenect", "--extra-lib-dirs=${pkgs.freenect}/lib"])))
5252 , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)
5353 , ("gi-cairo", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
54− , ("gi-gdk", giGdkPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
55− , ("gi-gdkpixbuf", giGdkPixBufPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
56− , ("gi-gio", giPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
57− , ("gi-glib", giPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
58− , ("gi-gobject", giPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
59− , ("gi-gst", gstLibOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
60− , ("gi-gstaudio", gstLibAudioOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
61− , ("gi-gstbase", gstLibAudioOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
62− , ("gi-gstvideo", gstLibAudioOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
63− , ("gi-gtk", giGtkPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
64− , ("gi-javascriptcore", giJavascriptCorePhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
54+ , ("gi-gst", giGstLibOverrides "gstreamer") -- https://github.com/haskell-gi/haskell-gi/issues/36
55+ , ("gi-gstaudio", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
56+ , ("gi-gstbase", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
57+ , ("gi-gstvideo", giGstLibOverrides "gst-plugins-base") -- https://github.com/haskell-gi/haskell-gi/issues/36
58+ , ("gi-javascriptcore < 4.0.0.0", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
6559 , ("gi-pango", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
66− , ("gi-pangocairo", giPangoCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
67− , ("gi-webkit2", giWebkit2PhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
68− , ("gi-webkit2webextension", giWebkit2PhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
60+ , ("gi-pangocairo", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36
61+ , ("gi-webkit", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
6962 , ("gio", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
7063 , ("git", set doCheck False) -- https://github.com/vincenthz/hit/issues/33
7164 , ("git-annex", gitAnnexHook)
@@ -120,6 +113,8 @@ hooks =
120113 , ("thyme", set (libraryDepends . tool . contains (bind "self.cpphs")) True) -- required on Darwin
121114 , ("twilio", set doCheck False) -- attempts to access the network
122115 , ("tz", set phaseOverrides "preConfigure = \"export TZDIR=${pkgs.tzdata}/share/zoneinfo\";")
116+ , ("webkitgtk3", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
117+ , ("webkitgtk3-javascriptcore", webkitgtk24xHook) -- https://github.com/haskell-gi/haskell-gi/issues/36
123118 , ("websockets", set doCheck False) -- https://github.com/jaspervdj/websockets/issues/104
124119 , ("Win32", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)))
125120 , ("Win32-shortcut", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)))
@@ -261,52 +256,14 @@ stackOverrides = unlines
261256 , "'';"
262257 ]
263258
264−exportGirSearchPath :: [String] -> String
265−exportGirSearchPath packages =
266− "export HASKELL_GI_GIR_SEARCH_PATH="
267− ++ intercalate ":" [ "${" ++ package ++ "}/share/gir-1.0" | package <- packages]
268−
269−giPhaseOverrides :: Derivation -> Derivation
270−giPhaseOverrides
271− = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["gobjectIntrospection.dev"] ++ "'';")
272− . set (libraryDepends . pkgconfig . contains (pkg "gobjectIntrospection")) True
273−
274−giGdkPhaseOverrides :: Derivation -> Derivation
275−giGdkPhaseOverrides
276− = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["gtk3.dev"] ++ "'';")
277−
278−gstLibOverrides :: Derivation -> Derivation
279−gstLibOverrides
280− = over (libraryDepends . pkgconfig) (replace (pkg "gstreamer") "gstreamer = pkgs.gst_all_1.gstreamer")
281−
282−gstLibAudioOverrides :: Derivation -> Derivation
283−gstLibAudioOverrides
284− = over (libraryDepends . pkgconfig) (replace (pkg "gst_plugins_base") "gst_plugins_base = pkgs.gst_all_1.gst-plugins-base")
285− . set (libraryDepends . system . contains (pkg "gobjectIntrospection")) True
286−
287−giGdkPixBufPhaseOverrides :: Derivation -> Derivation
288−giGdkPixBufPhaseOverrides
289− = set phaseOverrides (unlines
290− [ "preConfigure = ''"
291− , " " ++ exportGirSearchPath ["gobjectIntrospection.dev", "gdk_pixbuf.dev"]
292− , " export GI_TYPELIB_PATH=${gdk_pixbuf.out}/lib/girepository-1.0"
293− , "'';"
294− ])
295− . set (libraryDepends . pkgconfig . contains (pkg "gobjectIntrospection")) True
296−
297−giGtkPhaseOverrides :: Derivation -> Derivation
298−giGtkPhaseOverrides
299− = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["gtk3.dev"] ++ "'';")
300−
301−giJavascriptCorePhaseOverrides :: Derivation -> Derivation
302−giJavascriptCorePhaseOverrides
303− = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["webkitgtk"] ++ "'';")
304− . set (libraryDepends . pkgconfig . contains (pkg "webkitgtk")) True
259+-- Replace a binding for <package> to one to pkgs.gst_all_1.<package>
260+giGstLibOverrides :: String -> Derivation -> Derivation
261+giGstLibOverrides package
262+ = over (libraryDepends . pkgconfig) (replace (pkg (ident # package)) (binding # (ident # package, path # ["pkgs","gst_all_1", ident # package])))
305263
306264giCairoPhaseOverrides :: Derivation -> Derivation
307−giCairoPhaseOverrides = over phaseOverrides (++'\n':txt)
265+giCairoPhaseOverrides = over phaseOverrides (++txt)
308266 . set (libraryDepends . pkgconfig . contains (pkg "cairo")) True
309− . giPhaseOverrides
310267 where
311268 txt = unlines [ "preCompileBuildDriver = ''"
312269 , " PKG_CONFIG_PATH+=\":${cairo}/lib/pkgconfig\""
@@ -314,26 +271,6 @@ giCairoPhaseOverrides = over phaseOverrides (++'\n':txt)
314271 , "'';"
315272 ]
316273
317−giPangoCairoPhaseOverrides :: Derivation -> Derivation
318−giPangoCairoPhaseOverrides = set phaseOverrides txt
319− . over (libraryDepends . pkgconfig) addPkgs
320− where
321− addPkgs = Set.union (Set.fromList [ "system-pango = pkgs.pango"
322− , "system-cairo = pkgs.cairo" ])
323− . Set.insert (pkg "gobjectIntrospection")
324− gir = [ "system-pango.dev" ]
325− txt = unlines [ "preConfigure = ''" ++ exportGirSearchPath gir ++ "'';"
326− , "preCompileBuildDriver = ''"
327− , " PKG_CONFIG_PATH+=\":${system-pango.dev}/lib/pkgconfig:${system-cairo.dev}/lib/pkgconfig\""
328− , " setupCompileFlags+=\" $(pkg-config --libs pangocairo cairo-gobject)\""
329− , "'';"
330− ]
331−
332−giWebkit2PhaseOverrides :: Derivation -> Derivation
333−giWebkit2PhaseOverrides
334− = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["webkitgtk"] ++ "'';")
335− . set (libraryDepends . pkgconfig . contains (pkg "webkitgtk")) True
336−
337274hfseventsOverrides :: Derivation -> Derivation
338275hfseventsOverrides
339276 = set isLibrary True
@@ -341,3 +278,7 @@ hfseventsOverrides
341278 . set (libraryDepends . tool . contains (bind "pkgs.darwin.apple_sdk.frameworks.CoreServices")) True
342279 . set (libraryDepends . system . contains (bind "pkgs.darwin.apple_sdk.frameworks.Cocoa")) True
343280 . over (libraryDepends . haskell) (Set.union (Set.fromList (map bind ["self.base", "self.cereal", "self.mtl", "self.text", "self.bytestring"])))
281+
282+webkitgtk24xHook :: Derivation -> Derivation -- https://github.com/NixOS/cabal2nix/issues/145
283+webkitgtk24xHook = set (libraryDepends . pkgconfig . contains (pkg "webkitgtk24x")) True
284+ . over (libraryDepends . pkgconfig) (Set.filter (\b -> view localName b /= "webkitgtk24x"))