on iko/ghcjs-patch-master help sign in
Adds hooks
9151dffMoritz Angermann
builder/comp-builder.nix+24−2
@@ -9,7 +9,12 @@
9, flags
9, flags
10, cabalFile
10, cabalFile
11, patches ? []
11, patches ? []
12+
12−, postUnpack ? null
13+, preUnpack ? null, postUnpack ? null
14+, preConfigure ? null, postConfigure ? null
15+, preBuild ? null, postBuild ? null
16+, preCheck ? null, postCheck ? null
17+, preInstall ? null, postInstall ? null
13}:
18}:
14
19
15let
20let
@@ -160,29 +165,46 @@ in stdenv.mkDerivation ({
160 '';
165 '';
161
166
162 configurePhase = ''
167 configurePhase = ''
168+ runHook preConfigure
163 echo Configure flags:
169 echo Configure flags:
164 printf "%q " ${finalConfigureFlags}
170 printf "%q " ${finalConfigureFlags}
165 echo
171 echo
166 $SETUP_HS configure ${finalConfigureFlags}
172 $SETUP_HS configure ${finalConfigureFlags}
173+ runHook postConfigure
167 '';
174 '';
168
175
169 buildPhase = ''
176 buildPhase = ''
177+ runHook preBuild
170 $SETUP_HS build -j$NIX_BUILD_CORES ${lib.concatStringsSep " " component.setupBuildFlags}
178 $SETUP_HS build -j$NIX_BUILD_CORES ${lib.concatStringsSep " " component.setupBuildFlags}
179+ runHook postBuild
171 '';
180 '';
172
181
173 checkPhase = ''
182 checkPhase = ''
183+ runHook preCheck
174 $SETUP_HS test
184 $SETUP_HS test
185+ runHook postCheck
175 '';
186 '';
176
187
177 installPhase = ''
188 installPhase = ''
189+ runHook preInstall
178 $SETUP_HS copy
190 $SETUP_HS copy
179 ${lib.optionalString (haskellLib.isLibrary componentId) ''
191 ${lib.optionalString (haskellLib.isLibrary componentId) ''
180 $SETUP_HS register --gen-pkg-config=${name}.conf
192 $SETUP_HS register --gen-pkg-config=${name}.conf
181 ${ghc.targetPrefix}ghc-pkg init $out/package.conf.d
193 ${ghc.targetPrefix}ghc-pkg init $out/package.conf.d
182 ${ghc.targetPrefix}ghc-pkg --package-db ${configFiles}/package.conf.d -f $out/package.conf.d register ${name}.conf
194 ${ghc.targetPrefix}ghc-pkg --package-db ${configFiles}/package.conf.d -f $out/package.conf.d register ${name}.conf
183 ''}
195 ''}
196+ runHook postInstall
184 '';
197 '';
185}
198}
186// lib.optionalAttrs (patches != []) { inherit patches; }
199// lib.optionalAttrs (patches != []) { inherit patches; }
200+// lib.optionalAttrs (preUnpack != "") { inherit preUnpack; }
187−// lib.optionalAttrs (postUnpack != null) { inherit postUnpack; }
201+// lib.optionalAttrs (postUnpack != "") { inherit postUnpack; }
202+// lib.optionalAttrs (preConfigure != "") { inherit preConfigure; }
203+// lib.optionalAttrs (postConfigure != "") { inherit postConfigure; }
204+// lib.optionalAttrs (preBuild != "") { inherit preBuild; }
205+// lib.optionalAttrs (postBuild != "") { inherit postBuild; }
206+// lib.optionalAttrs (preCheck != "") { inherit preCheck; }
207+// lib.optionalAttrs (postCheck != "") { inherit postCheck; }
208+// lib.optionalAttrs (preInstall != "") { inherit preInstall; }
209+// lib.optionalAttrs (postInstall != "") { inherit postInstall; }
188)
210)
builder/default.nix+12−1
@@ -10,7 +10,17 @@
10, revision
10, revision
11, revisionSha256
11, revisionSha256
12, patches
12, patches
13+
14+, preUnpack
13, postUnpack
15, postUnpack
16+, preConfigure
17+, postConfigure
18+, preBuild
19+, postBuild
20+, preCheck
21+, postCheck
22+, preInstall
23+, postInstall
14
24
15, ...
25, ...
16}@config:
26}@config:
@@ -59,7 +69,8 @@ let
59 comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs; };
69 comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs; };
60
70
61 buildComp = componentId: component: comp-builder {
71 buildComp = componentId: component: comp-builder {
62− inherit componentId component package name src flags setup cabalFile patches postUnpack;
72+ inherit componentId component package name src flags setup cabalFile patches
73+ preUnpack postUnpack preConfigure postConfigure preBuild postBuild preCheck postCheck preInstall postInstall;
63 };
74 };
64
75
65in {
76in {
modules/package.nix+42−2
@@ -125,7 +125,7 @@ in {
125 };
125 };
126 setupBuildFlags = mkOption {
126 setupBuildFlags = mkOption {
127 type = listOfFilteringNulls str;
127 type = listOfFilteringNulls str;
128− default = [];
128+ default = config.setupBuildFlags;
129 };
129 };
130 doExactConfig = mkOption {
130 doExactConfig = mkOption {
131 type = bool;
131 type = bool;
@@ -185,9 +185,49 @@ in {
185 type = listOf (either package path);
185 type = listOf (either package path);
186 default = [];
186 default = [];
187 };
187 };
188+ setupBuildFlags = mkOption {
189+ type = listOfFilteringNulls str;
190+ default = [];
191+ };
188− postUnpack = mkOption {
192+ preUnpack = mkOption {
189 type = nullOr lines;
193 type = nullOr lines;
190 default = null;
194 default = null;
191 };
195 };
196+ postUnpack = mkOption {
197+ type = nullOr string;
198+ default = null;
199+ };
200+ preConfigure = mkOption {
201+ type = nullOr string;
202+ default = null;
203+ };
204+ postConfigure = mkOption {
205+ type = nullOr string;
206+ default = null;
207+ };
208+ preBuild = mkOption {
209+ type = nullOr string;
210+ default = null;
211+ };
212+ postBuild = mkOption {
213+ type = nullOr string;
214+ default = null;
215+ };
216+ preCheck = mkOption {
217+ type = nullOr string;
218+ default = null;
219+ };
220+ postCheck = mkOption {
221+ type = nullOr string;
222+ default = null;
223+ };
224+ preInstall = mkOption {
225+ type = nullOr string;
226+ default = null;
227+ };
228+ postInstall = mkOption {
229+ type = nullOr string;
230+ default = null;
231+ };
192 };
232 };
193}
233}