on iko/ghcjs-patch-master help sign in
Propagate hooks to the setup-builder (#321)
5d0b576Viktor Kronvall
builder/setup-builder.nix+14−2
@@ -1,7 +1,10 @@
1{ stdenv, lib, buildPackages, haskellLib, ghc, nonReinstallablePkgs, hsPkgs, makeSetupConfigFiles, pkgconfig }:
1{ stdenv, lib, buildPackages, haskellLib, ghc, nonReinstallablePkgs, hsPkgs, makeSetupConfigFiles, pkgconfig }:
2
2
3{ component, package, name, src, flags, revision, patches, defaultSetupSrc
3{ component, package, name, src, flags, revision, patches, defaultSetupSrc
4−, preUnpack ? null, postUnpack ? null
4+, preUnpack ? component.preUnpack, postUnpack ? component.postUnpack
5+, prePatch ? null, postPatch ? null
6+, preBuild ? component.preBuild , postBuild ? component.postBuild
7+, preInstall ? component.preInstall , postInstall ? component.postInstall
5}:
8}:
6
9
7let
10let
@@ -16,7 +19,12 @@ let
16 inherit fullName flags component;
19 inherit fullName flags component;
17 };
20 };
18 hooks = haskellLib.optionalHooks {
21 hooks = haskellLib.optionalHooks {
22+ inherit
19− inherit preUnpack postUnpack;
23+ preUnpack postUnpack
24+ prePatch postPatch
25+ preBuild postBuild
26+ preInstall postInstall
27+ ;
20 };
28 };
21
29
22 executableToolDepends =
30 executableToolDepends =
@@ -54,6 +62,7 @@ in
54
62
55 phases = ["unpackPhase" "patchPhase" "buildPhase" "installPhase"];
63 phases = ["unpackPhase" "patchPhase" "buildPhase" "installPhase"];
56 buildPhase = ''
64 buildPhase = ''
65+ runHook preBuild
57 if [[ ! -f ./Setup.hs && ! -f ./Setup.lhs ]]; then
66 if [[ ! -f ./Setup.hs && ! -f ./Setup.lhs ]]; then
58 cat ${defaultSetupSrc} > Setup.hs
67 cat ${defaultSetupSrc} > Setup.hs
59 fi
68 fi
@@ -66,11 +75,14 @@ in
66 fi
75 fi
67 done
76 done
68 [ -f ./Setup ] || (echo Failed to build Setup && exit 1)
77 [ -f ./Setup ] || (echo Failed to build Setup && exit 1)
78+ runHook preBuild
69 '';
79 '';
70
80
71 installPhase = ''
81 installPhase = ''
82+ runHook preInstall
72 mkdir -p $out/bin
83 mkdir -p $out/bin
73 install ./Setup $out/bin/Setup
84 install ./Setup $out/bin/Setup
85+ runHook postInstall
74 '';
86 '';
75 }
87 }
76 // (lib.optionalAttrs (patches != []) { patches = map (p: if builtins.isFunction p then p { inherit (package.identifier) version; inherit revision; } else p) patches; })
88 // (lib.optionalAttrs (patches != []) { patches = map (p: if builtins.isFunction p then p { inherit (package.identifier) version; inherit revision; } else p) patches; })