1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

automatic phpunit version

This commit is contained in:
Robin Appelman 2025-08-26 16:39:44 +02:00
commit 57dd81faf9
2 changed files with 54 additions and 19 deletions

View file

@ -29,9 +29,11 @@
su, su,
which, which,
clamav, clamav,
jq,
debug ? false, debug ? false,
writeShellApplication, writeShellApplication,
}: let }: let
inherit (builtins) toString;
inherit (lib) readFile getExe concatStringsSep splitString take; inherit (lib) readFile getExe concatStringsSep splitString take;
phpVersion = concatStringsSep "." (take 2 (splitString "." php.version)); phpVersion = concatStringsSep "." (take 2 (splitString "." php.version));
@ -65,7 +67,46 @@
''; '';
configs = callPackage ./configs.nix {}; configs = callPackage ./configs.nix {};
scripts = callPackage ./scripts.nix {}; scripts = callPackage ./scripts.nix {};
phpunit = callPackage ./phpunit.nix {php = phpEnv;}; phpunitUnwrapped = majorVersion:
callPackage ./phpunit.nix {
inherit majorVersion;
php = phpEnv;
};
phpunitWrapped = majorVersion:
writeShellApplication {
name = "phpunit${toString majorVersion}";
text = ''
${phpunitUnwrapped (toString majorVersion)}/bin/phpunit "$@"
'';
};
phpunit = writeShellApplication {
name = "phpunit";
runtimeInputs = [jq];
text = ''
MAJOR=$(jq -r 'first(.require."phpunit/phpunit" | scan("[[:digit:]]+"))' vendor-bin/phpunit/composer.json)
case "$MAJOR" in
9)
PKG=${phpunitUnwrapped "9"}
;;
10)
PKG=${phpunitUnwrapped "10"}
;;
11)
PKG=${phpunitUnwrapped "11"}
;;
12)
PKG=${phpunitUnwrapped "12"}
;;
*)
PKG=${phpunitUnwrapped "10"}
;;
esac
"$PKG"/bin/phpunit "$@"
'';
};
redis-certificates = runCommand "scripts" {} '' redis-certificates = runCommand "scripts" {} ''
mkdir -p $out mkdir -p $out
cp -r ${../../redis-certificates} $out/redis-certificates cp -r ${../../redis-certificates} $out/redis-certificates

View file

@ -3,6 +3,7 @@
fetchFromGitHub, fetchFromGitHub,
nix-update-script, nix-update-script,
php, php,
majorVersion,
phpunit, phpunit,
testers, testers,
versionCheckHook, versionCheckHook,
@ -10,22 +11,22 @@
inherit (lib) concatStringsSep splitString take; inherit (lib) concatStringsSep splitString take;
phpVersion = concatStringsSep "." (take 2 (splitString "." php.version)); phpVersion = concatStringsSep "." (take 2 (splitString "." php.version));
versions = { versions = {
"8.1" = { "9" = {
version = "9.6.25";
hash = "sha256-DKbInG8zsIa2DFNY5eqW8CKWUhGM0yc3/wppUiizYbg=";
vendorHash = "sha256-pvP2ULwnDbPb9bIaNKkQ7cvyMpgZiFfoJfUFRGzojBQ=";
};
"10" = {
version = "10.5.46"; version = "10.5.46";
hash = "sha256-DtQ6CR4RAGKpZcJA9WZ5ud5ztIBTr8MeVTIhFwbGHYc="; hash = "sha256-DtQ6CR4RAGKpZcJA9WZ5ud5ztIBTr8MeVTIhFwbGHYc=";
vendorHash = "sha256-fNv9pWFwYTyw3KEGtmbKNzXFsiDE6oZjRCWhypa/k0A="; vendorHash = "sha256-fNv9pWFwYTyw3KEGtmbKNzXFsiDE6oZjRCWhypa/k0A=";
}; };
"8.2" = { "11" = {
version = "11.5.22"; version = "11.5.22";
hash = "sha256-oXoh/2G0bqPPyvVoQUUdUz8XGyNtRJE3taUFGu2UIsc="; hash = "sha256-oXoh/2G0bqPPyvVoQUUdUz8XGyNtRJE3taUFGu2UIsc=";
vendorHash = "sha256-9gLTJe2ft90qGr/d8/Zc/ua7EWyNZ16wPEZRe9sKZf0="; vendorHash = "sha256-9gLTJe2ft90qGr/d8/Zc/ua7EWyNZ16wPEZRe9sKZf0=";
}; };
"8.3" = { "12" = {
version = "12.2.1";
hash = "sha256-D5WI1kv05L8X3Gfw/MCxGdIcqWyWJg68GL9I24z/zIY=";
vendorHash = "sha256-H+XMRMvbUz/WCUdPRmL8nSCqa5YE3Qb1+goEQjjDK70=";
};
"8.4" = {
version = "12.2.1"; version = "12.2.1";
hash = "sha256-D5WI1kv05L8X3Gfw/MCxGdIcqWyWJg68GL9I24z/zIY="; hash = "sha256-D5WI1kv05L8X3Gfw/MCxGdIcqWyWJg68GL9I24z/zIY=";
vendorHash = "sha256-H+XMRMvbUz/WCUdPRmL8nSCqa5YE3Qb1+goEQjjDK70="; vendorHash = "sha256-H+XMRMvbUz/WCUdPRmL8nSCqa5YE3Qb1+goEQjjDK70=";
@ -34,23 +35,16 @@
in in
php.buildComposerProject2 (finalAttrs: { php.buildComposerProject2 (finalAttrs: {
pname = "phpunit"; pname = "phpunit";
inherit (versions.${phpVersion}) version vendorHash; inherit (versions.${majorVersion}) version vendorHash;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "sebastianbergmann"; owner = "sebastianbergmann";
repo = "phpunit"; repo = "phpunit";
tag = finalAttrs.version; tag = finalAttrs.version;
inherit (versions.${phpVersion}) hash; inherit (versions.${majorVersion}) hash;
}; };
passthru = { doInstallCheck = false;
updateScript = nix-update-script {};
tests.version = testers.testVersion {package = phpunit;};
};
doInstallCheck = true;
nativeInstallCheckInputs = [versionCheckHook];
versionCheckProgramArg = "--version";
meta = { meta = {
changelog = "https://github.com/sebastianbergmann/phpunit/blob/${finalAttrs.version}/ChangeLog-${lib.versions.majorMinor finalAttrs.version}.md"; changelog = "https://github.com/sebastianbergmann/phpunit/blob/${finalAttrs.version}/ChangeLog-${lib.versions.majorMinor finalAttrs.version}.md";