@@ -1,4 +1,4 @@
1−{ stdenv, buildPackages, ghc, lib, pkgconfig, writeText, runCommand, haskellLib, nonReinstallablePkgs, withPackage }:
1+{ stdenv, buildPackages, ghc, lib, pkgconfig, writeText, runCommand, haskellLib, nonReinstallablePkgs, withPackage, hsPkgs }:
22
33{ componentId
44, component
@@ -9,6 +9,7 @@
99, flags
1010, revision
1111, cabalFile
12+, cabal-generator
1213, patches ? []
1314
1415, preUnpack ? null, postUnpack ? null
@@ -242,9 +243,11 @@ stdenv.mkDerivation ({
242243 # Phases
243244 preInstallPhases = lib.optional doHaddock' "haddockPhase";
244245
245− prePatch = lib.optionalString (cabalFile != null) ''
246− cat ${cabalFile} > ${package.identifier.name}.cabal
247− '';
246+ prePatch = if (cabalFile != null)
247+ then ''cat ${cabalFile} > ${package.identifier.name}.cabal''
248+ else lib.optionalString (cabal-generator == "hpack") ''
249+ ${hsPkgs.hpack.components.exes.hpack}/bin/hpack
250+ '';
248251
249252 configurePhase = ''
250253 runHook preConfigure