From a1d78fa5bc92d4946a9c8ecdcf71ad548e11cb0b Mon Sep 17 00:00:00 2001
From: Nicholas Clarke <nick@topos.org.uk>
Date: Tue, 15 Aug 2017 14:46:00 +0100
Subject: [PATCH] Don't build separate bin output for alex.

It has files in /usr/share which reference the bin output.
---
 pkgs/development/haskell-modules/configuration-nix.nix | 3 +++
 pkgs/development/haskell-modules/lib.nix               | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix
index 36f5f28f2f8..83ed62c7de0 100644
--- a/pkgs/development/haskell-modules/configuration-nix.nix
+++ b/pkgs/development/haskell-modules/configuration-nix.nix
@@ -489,4 +489,7 @@ self: super: builtins.intersectAttrs super {
   # Without this override, the builds lacks pkg-config.
   opencv-extra = addPkgconfigDepend super.opencv-extra (pkgs.opencv3.override { enableContrib = true; });
 
+  # Alex has some weird files in /usr/share that create a cyclic ref with
+  # its bin dir.
+  alex = hasNoBinOutput super.alex;
 }
diff --git a/pkgs/development/haskell-modules/lib.nix b/pkgs/development/haskell-modules/lib.nix
index 518c3c82e6c..fbfd5ae6b94 100644
--- a/pkgs/development/haskell-modules/lib.nix
+++ b/pkgs/development/haskell-modules/lib.nix
@@ -142,6 +142,8 @@ rec {
   overrideSrc = drv: { src, version ? drv.version }:
     overrideCabal drv (_: { inherit src version; editedCabalFile = null; });
 
+  hasNoBinOutput = drv: overrideCabal drv (drv: { enableSeparateBinOutput = false; });
+
   installOutputs = drv: outputs: overrideCabal drv
     (drv: { outputsToInstall = outputs; });
 }