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,
which,
clamav,
jq,
debug ? false,
writeShellApplication,
}: let
inherit (builtins) toString;
inherit (lib) readFile getExe concatStringsSep splitString take;
phpVersion = concatStringsSep "." (take 2 (splitString "." php.version));
@ -65,7 +67,46 @@
'';
configs = callPackage ./configs.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" {} ''
mkdir -p $out
cp -r ${../../redis-certificates} $out/redis-certificates