on iko/ghcjs-patch-master help sign in
Improve hpack support (#800)

Use up to date hpack in comp-builder.nix Avoid running hpack when we have a .cabal file already

commita904d403d869a8a73b3c77f812f84682f37df4e9 authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateWed 5 Aug 2020, 01:02 (6 years ago) parentafbb245
3 files changed+21−8
builder/comp-builder.nix+2−2 builder/default.nix+1−1 lib/call-cabal-project-to-nix.nix+18−5
builder/comp-builder.nix+2−2
@@ -1,4 +1,4 @@
1−{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, runCommand, libffi, gmp, zlib, ncurses, numactl, nodejs }:
1+{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, zlib, ncurses, numactl, nodejs }:
22lib.makeOverridable (
33let self =
44{ componentId
@@ -175,7 +175,7 @@ let
175175 prePatch = if (cabalFile != null)
176176 then ''cat ${cabalFile} > ${package.identifier.name}.cabal''
177177 else lib.optionalString (cabal-generator == "hpack") ''
178− ${buildPackages.haskell-nix.haskellPackages.hpack.components.exes.hpack}/bin/hpack
178+ ${buildPackages.haskell-nix.nix-tools.${compiler.nix-name}}/bin/hpack
179179 '';
180180 }
181181 # patches can (if they like) depend on the version and revision of the package.
builder/default.nix+1−1
@@ -3,7 +3,7 @@
33let
44 # Builds a single component of a package.
55 comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix {
6− inherit ghc haskellLib makeConfigFiles haddockBuilder ghcForComponent hsPkgs;
6+ inherit ghc haskellLib makeConfigFiles haddockBuilder ghcForComponent hsPkgs compiler;
77 };
88
99 haddockBuilder = haskellLib.weakCallPackage pkgs ./haddock-builder.nix {
lib/call-cabal-project-to-nix.nix+18−5
@@ -340,11 +340,24 @@ let
340340 fi
341341 cp -r ${maybeCleanedSource}/* .
342342 chmod +w -R .
343− # warning: this may not generate the proper cabal file.
344− # hpack allows globbing, and turns that into module lists
345− # without the source available (we cleaneSourceWith'd it),
346− # this may not produce the right result.
347− find . -name package.yaml -exec hpack "{}" \;
343+ # Decide what to do for each `package.yaml` file.
344+ for hpackFile in $(find . -name package.yaml); do (
345+ # Look to see if a `.cabal` file exists
346+ shopt -u nullglob
347+ for cabalFile in $(dirname $hpackFile)/*.cabal; do
348+ if [ -e "$cabalFile" ]; then
349+ echo Ignoring $hpackFile as $cabalFile exists
350+ else
351+ # warning: this may not generate the proper cabal file.
352+ # hpack allows globbing, and turns that into module lists
353+ # without the source available (we cleaneSourceWith'd it),
354+ # this may not produce the right result.
355+ echo No .cabal file found, running hpack on $hpackFile
356+ hpack $hpackFile
357+ fi
358+ done
359+ )
360+ done
348361 ${pkgs.lib.optionalString (subDir != "") "cd ${subDir}"}
349362 ${fixedProject.makeFixedProjectFile}
350363 ${pkgs.lib.optionalString (cabalProjectFreeze != null) ''