core/pkgs/build-support/php/build-composer-project.nix

105 lines
2.8 KiB
Nix
Raw Normal View History

2024-06-30 08:16:52 +00:00
{
callPackage,
stdenvNoCC,
lib,
writeTextDir,
php,
makeBinaryWrapper,
fetchFromGitHub,
fetchurl,
}:
2024-05-02 00:46:19 +00:00
let
2024-06-30 08:16:52 +00:00
buildComposerProjectOverride =
finalAttrs: previousAttrs:
2024-05-02 00:46:19 +00:00
let
phpDrv = finalAttrs.php or php;
composer = finalAttrs.composer or phpDrv.packages.composer;
composer-local-repo-plugin = callPackage ./pkgs/composer-local-repo-plugin.nix { };
in
{
composerLock = previousAttrs.composerLock or null;
composerNoDev = previousAttrs.composerNoDev or true;
composerNoPlugins = previousAttrs.composerNoPlugins or true;
composerNoScripts = previousAttrs.composerNoScripts or true;
composerStrictValidation = previousAttrs.composerStrictValidation or true;
nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ [
composer
composer-local-repo-plugin
phpDrv
phpDrv.composerHooks.composerInstallHook
];
2024-06-30 08:16:52 +00:00
buildInputs = (previousAttrs.buildInputs or [ ]) ++ [ phpDrv ];
2024-05-02 00:46:19 +00:00
patches = previousAttrs.patches or [ ];
strictDeps = previousAttrs.strictDeps or true;
# Should we keep these empty phases?
2024-06-30 08:16:52 +00:00
configurePhase =
previousAttrs.configurePhase or ''
runHook preConfigure
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
runHook postConfigure
'';
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
buildPhase =
previousAttrs.buildPhase or ''
runHook preBuild
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
runHook postBuild
'';
2024-05-02 00:46:19 +00:00
doCheck = previousAttrs.doCheck or true;
2024-06-30 08:16:52 +00:00
checkPhase =
previousAttrs.checkPhase or ''
runHook preCheck
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
runHook postCheck
'';
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
installPhase =
previousAttrs.installPhase or ''
runHook preInstall
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
runHook postInstall
'';
2024-05-02 00:46:19 +00:00
doInstallCheck = previousAttrs.doInstallCheck or false;
2024-06-30 08:16:52 +00:00
installCheckPhase =
previousAttrs.installCheckPhase or ''
runHook preInstallCheck
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
runHook postInstallCheck
'';
2024-05-02 00:46:19 +00:00
composerRepository = phpDrv.mkComposerRepository {
inherit composer composer-local-repo-plugin;
2024-06-30 08:16:52 +00:00
inherit (finalAttrs)
patches
pname
src
vendorHash
version
;
2024-05-02 00:46:19 +00:00
composerLock = previousAttrs.composerLock or null;
composerNoDev = previousAttrs.composerNoDev or true;
composerNoPlugins = previousAttrs.composerNoPlugins or true;
composerNoScripts = previousAttrs.composerNoScripts or true;
composerStrictValidation = previousAttrs.composerStrictValidation or true;
};
2024-06-30 08:16:52 +00:00
COMPOSER_CACHE_DIR = "/dev/null";
COMPOSER_DISABLE_NETWORK = "1";
COMPOSER_MIRROR_PATH_REPOS = "1";
2024-05-02 00:46:19 +00:00
meta = previousAttrs.meta or { } // {
platforms = lib.platforms.all;
};
};
in
args: (stdenvNoCC.mkDerivation args).overrideAttrs buildComposerProjectOverride