diff --git a/builder/comp-builder.nix b/builder/comp-builder.nix index 71388f7f..6a97f1d8 100644 --- a/builder/comp-builder.nix +++ b/builder/comp-builder.nix @@ -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; } ) diff --git a/builder/default.nix b/builder/default.nix index ffb00d4d..ec9191ef 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -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 { diff --git a/modules/package.nix b/modules/package.nix index b9b7af30..cc7aadaa 100644 --- a/modules/package.nix +++ b/modules/package.nix @@ -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; + }; }; }