Adds hooks

This commit is contained in:
Moritz Angermann
2018-11-26 17:26:18 +08:00
parent 5a750e0890
commit 9151dff3f3
3 changed files with 78 additions and 5 deletions
+24 -2
View File
@@ -9,7 +9,12 @@
, flags
, cabalFile
, patches ? []
, postUnpack ? null
, preUnpack ? null, postUnpack ? null
, preConfigure ? null, postConfigure ? null
, preBuild ? null, postBuild ? null
, preCheck ? null, postCheck ? null
, preInstall ? null, postInstall ? null
}:
let
@@ -160,29 +165,46 @@ in stdenv.mkDerivation ({
'';
configurePhase = ''
runHook preConfigure
echo Configure flags:
printf "%q " ${finalConfigureFlags}
echo
$SETUP_HS configure ${finalConfigureFlags}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
$SETUP_HS build -j$NIX_BUILD_CORES ${lib.concatStringsSep " " component.setupBuildFlags}
runHook postBuild
'';
checkPhase = ''
runHook preCheck
$SETUP_HS test
runHook postCheck
'';
installPhase = ''
runHook preInstall
$SETUP_HS copy
${lib.optionalString (haskellLib.isLibrary componentId) ''
$SETUP_HS register --gen-pkg-config=${name}.conf
${ghc.targetPrefix}ghc-pkg init $out/package.conf.d
${ghc.targetPrefix}ghc-pkg --package-db ${configFiles}/package.conf.d -f $out/package.conf.d register ${name}.conf
''}
runHook postInstall
'';
}
// lib.optionalAttrs (patches != []) { inherit patches; }
// lib.optionalAttrs (postUnpack != null) { inherit postUnpack; }
// lib.optionalAttrs (preUnpack != "") { inherit preUnpack; }
// lib.optionalAttrs (postUnpack != "") { inherit postUnpack; }
// lib.optionalAttrs (preConfigure != "") { inherit preConfigure; }
// lib.optionalAttrs (postConfigure != "") { inherit postConfigure; }
// lib.optionalAttrs (preBuild != "") { inherit preBuild; }
// lib.optionalAttrs (postBuild != "") { inherit postBuild; }
// lib.optionalAttrs (preCheck != "") { inherit preCheck; }
// lib.optionalAttrs (postCheck != "") { inherit postCheck; }
// lib.optionalAttrs (preInstall != "") { inherit preInstall; }
// lib.optionalAttrs (postInstall != "") { inherit postInstall; }
)
+12 -1
View File
@@ -10,7 +10,17 @@
, revision
, revisionSha256
, patches
, preUnpack
, postUnpack
, preConfigure
, postConfigure
, preBuild
, postBuild
, preCheck
, postCheck
, preInstall
, postInstall
, ...
}@config:
@@ -59,7 +69,8 @@ let
comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs; };
buildComp = componentId: component: comp-builder {
inherit componentId component package name src flags setup cabalFile patches postUnpack;
inherit componentId component package name src flags setup cabalFile patches
preUnpack postUnpack preConfigure postConfigure preBuild postBuild preCheck postCheck preInstall postInstall;
};
in {
+42 -2
View File
@@ -125,7 +125,7 @@ in {
};
setupBuildFlags = mkOption {
type = listOfFilteringNulls str;
default = [];
default = config.setupBuildFlags;
};
doExactConfig = mkOption {
type = bool;
@@ -185,9 +185,49 @@ in {
type = listOf (either package path);
default = [];
};
postUnpack = mkOption {
setupBuildFlags = mkOption {
type = listOfFilteringNulls str;
default = [];
};
preUnpack = mkOption {
type = nullOr lines;
default = null;
};
postUnpack = mkOption {
type = nullOr string;
default = null;
};
preConfigure = mkOption {
type = nullOr string;
default = null;
};
postConfigure = mkOption {
type = nullOr string;
default = null;
};
preBuild = mkOption {
type = nullOr string;
default = null;
};
postBuild = mkOption {
type = nullOr string;
default = null;
};
preCheck = mkOption {
type = nullOr string;
default = null;
};
postCheck = mkOption {
type = nullOr string;
default = null;
};
preInstall = mkOption {
type = nullOr string;
default = null;
};
postInstall = mkOption {
type = nullOr string;
default = null;
};
};
}