about summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorSimon Chatterjee <code@chatts.net>2020-02-17 20:29:19 +0000
committerPeter Simons <simons@cryp.to>2020-02-28 20:31:24 +0100
commitfdb4ed35edc8fbdd952fb7ec91b9eafddd40f55e (patch)
tree2bbb8f3a552a3f77e7c330d4ccad33a6cf4479ab /pkgs/development
parent524535f18532203c9835ce20eaf7b9839a8be7f7 (diff)
downloadnixlib-fdb4ed35edc8fbdd952fb7ec91b9eafddd40f55e.tar
nixlib-fdb4ed35edc8fbdd952fb7ec91b9eafddd40f55e.tar.gz
nixlib-fdb4ed35edc8fbdd952fb7ec91b9eafddd40f55e.tar.bz2
nixlib-fdb4ed35edc8fbdd952fb7ec91b9eafddd40f55e.tar.lz
nixlib-fdb4ed35edc8fbdd952fb7ec91b9eafddd40f55e.tar.xz
nixlib-fdb4ed35edc8fbdd952fb7ec91b9eafddd40f55e.tar.zst
nixlib-fdb4ed35edc8fbdd952fb7ec91b9eafddd40f55e.zip
haskell-gtk2hs packges: fixes for building on Darwin
This includes two layered changes so the gtk2hs packages build on Darwin:

 - For `glib`, `gio`, `gtk`, `gtk3`, and `pango`: the fix for version 0.13.8.0
   from https://github.com/gtk2hs/gtk2hs/pull/293 . I expect at some point the
   referenced fix (or one like it) will be released and and brought into
   nixpkgs, at which point the override and patch files here can (in fact must)
   be removed.

 - For `gtk` and `gtk3`: also apply the required cabal flag cited in
   https://github.com/gtk2hs/gtk2hs/issues/249 to specify the Quartz rather than
   X11 backend (Quartz is the one that both nixpkgs and macOS support
   out-the-box). This override is likely to be wanted indefinitely.

Both modifications are required for a successful build of `gtk` or `gtk3` on
Darwin right now.
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/haskell-modules/configuration-common.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix
index 13ce36eff06d..086c8c8df64c 100644
--- a/pkgs/development/haskell-modules/configuration-common.nix
+++ b/pkgs/development/haskell-modules/configuration-common.nix
@@ -1406,4 +1406,58 @@ self: super: {
   # cabal-fmt requires Cabal3
   cabal-fmt = super.cabal-fmt.override { Cabal = self.Cabal_3_0_0_0; };
 
+  # Several gtk2hs-provided packages at v0.13.8.0 fail to build on Darwin
+  # until we pick up https://github.com/gtk2hs/gtk2hs/pull/293 so apply that
+  # patch here. That single patch is for the gtk2hs super-repo, out of which
+  # we extract the patch for each indvidiual project (glib/gio/pango/gtk/gtk3).
+  glib = appendPatch super.glib (pkgs.fetchpatch {
+    url = "https://github.com/gtk2hs/gtk2hs/commit/1cf2f9bff2427d39986e32880d1383cfff49ab0e.patch";
+    includes = [ "glib.cabal" ];
+    stripLen = 1;
+    sha256 = "1zdss1xgsbijs3kx8dp5a81qryrfc1zm1xrd20whna3dqakf8b7g";
+  });
+  gio = appendPatch super.gio (pkgs.fetchpatch {
+    url = "https://github.com/gtk2hs/gtk2hs/commit/1cf2f9bff2427d39986e32880d1383cfff49ab0e.patch";
+    includes = [ "gio.cabal" ];
+    stripLen = 1;
+    sha256 = "0d72k6gqvgax9jcqi3gz1gqnar7jg8p5065z3mw2fcwvdw46s2zv";
+  });
+  pango = appendPatch super.pango (pkgs.fetchpatch {
+    url = "https://github.com/gtk2hs/gtk2hs/commit/1cf2f9bff2427d39986e32880d1383cfff49ab0e.patch";
+    includes = [ "pango.cabal" ];
+    stripLen = 1;
+    sha256 = "0dc221wlmyhc24h6ybfhbkxmcx4i6bvkbr1zgqidbnj3yp6w0l5w";
+  });
+  # gtk/gtk3 have an additional complication: independent of the above
+  # 0.13.8.0-specific fix, they need to be told on Darwin to use the Quartz
+  # rather than X11 backend (see eg https://github.com/gtk2hs/gtk2hs/issues/249).
+  gtk3 =
+    let
+      patchedGtk3 = appendPatch super.gtk3 (pkgs.fetchpatch {
+        url = "https://github.com/gtk2hs/gtk2hs/commit/1cf2f9bff2427d39986e32880d1383cfff49ab0e.patch";
+        includes = [ "gtk3.cabal" ];
+        stripLen = 1;
+        sha256 = "0zvj0dzfwf9bksfhi0m4v0h5aij236gd0qhyr1adpdcjrkd8zbkd";
+      });
+    in
+      # The appendConfigureFlags should remain even after we can drop patchedGtk3.
+      appendConfigureFlags patchedGtk3 (pkgs.lib.optional pkgs.stdenv.isDarwin "-f have-quartz-gtk");
+  gtk =
+    let
+      patchedGtk = appendPatch super.gtk (pkgs.fetchpatch {
+        url = "https://github.com/gtk2hs/gtk2hs/commit/1cf2f9bff2427d39986e32880d1383cfff49ab0e.patch";
+        includes = [ "gtk.cabal-renamed" ];
+        stripLen = 1;
+        sha256 = "0wb0scvmhg8b42hxpns9m6zak3r8b25a2z7wg6vl56n17nb635l7";
+        # One final complication: the gtk cabal file in the source repo (as seen
+        # by the patch) is `gtk.cabal-renamed`, but this gets changed to the usual
+        # `gtk.cabal` before uploading to Hackage by a script.
+        postFetch = ''
+          substituteInPlace $out --replace "-renamed" ""
+        '';
+      });
+    in
+      # The appendConfigureFlags should remain even after we can drop patchedGtk.
+      appendConfigureFlags patchedGtk (pkgs.lib.optional pkgs.stdenv.isDarwin "-f have-quartz-gtk");
+
 } // import ./configuration-tensorflow.nix {inherit pkgs haskellLib;} self super