Skip to content

Commit 3c78fda

Browse files
qrilkaangerman
authored andcommitted
Use hpack to generate cabal files when required (#82)
* Use hpack to generate cabal files when required
1 parent 0b2d033 commit 3c78fda

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

builder/comp-builder.nix

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

builder/default.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, buildGHC, fetchurl, writeText, runCommand, pkgconfig, nonReinstallablePkgs, withPackage }:
1+
{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, buildGHC, fetchurl, writeText, runCommand, pkgconfig, nonReinstallablePkgs, withPackage, hsPkgs }:
22

33
{ flags
44
, package
55
, components
6+
, cabal-generator
67

78
, name
89
, sha256
@@ -71,10 +72,10 @@ let
7172
'';
7273
};
7374

74-
comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs withPackage; };
75+
comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs withPackage hsPkgs; };
7576

7677
buildComp = componentId: component: comp-builder {
77-
inherit componentId component package name src flags setup cabalFile patches revision
78+
inherit componentId component package name src flags setup cabalFile cabal-generator patches revision
7879
preUnpack postUnpack preConfigure postConfigure
7980
preBuild postBuild preCheck postCheck
8081
preInstall postInstall preHaddock postHaddock

modules/component-driver.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let
55
inherit haskellLib;
66
ghc = config.ghc.package;
77
buildGHC = buildModules.config.ghc.package;
8-
inherit (config) nonReinstallablePkgs;
8+
inherit (config) nonReinstallablePkgs hsPkgs;
99
inherit withPackage;
1010
};
1111

0 commit comments

Comments
 (0)