on iko/ghcjs-patch-master help sign in
Use hpack to generate cabal files when required (#82)
3c78fdaKirill Zaborsky
builder/comp-builder.nix+7−4
@@ -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 }:
2
2
3{ componentId
3{ componentId
4, component
4, component
@@ -9,6 +9,7 @@
9, flags
9, flags
10, revision
10, revision
11, cabalFile
11, cabalFile
12+, cabal-generator
12, patches ? []
13, patches ? []
13
14
14, preUnpack ? null, postUnpack ? null
15, preUnpack ? null, postUnpack ? null
@@ -242,9 +243,11 @@ stdenv.mkDerivation ({
242 # Phases
243 # Phases
243 preInstallPhases = lib.optional doHaddock' "haddockPhase";
244 preInstallPhases = lib.optional doHaddock' "haddockPhase";
244
245
245− prePatch = lib.optionalString (cabalFile != null) ''
246+ prePatch = if (cabalFile != null)
246− cat ${cabalFile} > ${package.identifier.name}.cabal
247+ then ''cat ${cabalFile} > ${package.identifier.name}.cabal''
248+ else lib.optionalString (cabal-generator == "hpack") ''
249+ ${hsPkgs.hpack.components.exes.hpack}/bin/hpack
247− '';
250+ '';
248
251
249 configurePhase = ''
252 configurePhase = ''
250 runHook preConfigure
253 runHook preConfigure
builder/default.nix+4−3
@@ -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 }:
2
2
3{ flags
3{ flags
4, package
4, package
5, components
5, components
6+, cabal-generator
6
7
7, name
8, name
8, sha256
9, sha256
@@ -71,10 +72,10 @@ let
71 '';
72 '';
72 };
73 };
73
74
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; };
75
76
76 buildComp = componentId: component: comp-builder {
77 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
78 preUnpack postUnpack preConfigure postConfigure
79 preUnpack postUnpack preConfigure postConfigure
79 preBuild postBuild preCheck postCheck
80 preBuild postBuild preCheck postCheck
80 preInstall postInstall preHaddock postHaddock
81 preInstall postInstall preHaddock postHaddock
modules/component-driver.nix+1−1
@@ -5,7 +5,7 @@ let
5 inherit haskellLib;
5 inherit haskellLib;
6 ghc = config.ghc.package;
6 ghc = config.ghc.package;
7 buildGHC = buildModules.config.ghc.package;
7 buildGHC = buildModules.config.ghc.package;
8− inherit (config) nonReinstallablePkgs;
8+ inherit (config) nonReinstallablePkgs hsPkgs;
9 inherit withPackage;
9 inherit withPackage;
10 };
10 };
11
11