phpPackages.mkDerivation: use lib.{fix,extends} instead of //

// on a overrideAttrs'able works badly

here we use lib.fix and lib.extends instead of overrideAttrs to have
less of a performance impact
This commit is contained in:
Artturin 2023-02-08 19:34:41 +02:00
parent 315664758c
commit 4d32075a0e
2 changed files with 22 additions and 15 deletions

View File

@ -1,11 +1,11 @@
{ mkDerivation, fetchurl, makeWrapper, lib, php }:
mkDerivation rec {
mkDerivation (finalAttrs: {
pname = "grumphp";
version = "1.15.0";
src = fetchurl {
url = "https://github.com/phpro/${pname}/releases/download/v${version}/${pname}.phar";
url = "https://github.com/phpro/grumphp/releases/download/v${finalAttrs.version}/grumphp.phar";
sha256 = "sha256-EqzJb7DYZb7PnebErLVI/EZLxj0m26cniZlsu1feif0=";
};
@ -16,17 +16,17 @@ mkDerivation rec {
installPhase = ''
runHook preInstall
mkdir -p $out/bin
install -D $src $out/libexec/${pname}/grumphp.phar
install -D $src $out/libexec/grumphp/grumphp.phar
makeWrapper ${php}/bin/php $out/bin/grumphp \
--add-flags "$out/libexec/${pname}/grumphp.phar"
--add-flags "$out/libexec/grumphp/grumphp.phar"
runHook postInstall
'';
meta = with lib; {
changelog = "https://github.com/phpro/grumphp/releases/tag/v${version}";
changelog = "https://github.com/phpro/grumphp/releases/tag/v${finalAttrs.version}";
description = "A PHP code-quality tool";
homepage = "https://github.com/phpro/grumphp";
license = licenses.mit;
maintainers = teams.php.members;
};
}
})

View File

@ -57,15 +57,22 @@ lib.makeScope pkgs.newScope (self: with self; {
# Wrap mkDerivation to prepend pname with "php-" to make names consistent
# with how buildPecl does it and make the file easier to overview.
mkDerivation = { pname, ... }@args: pkgs.stdenv.mkDerivation (args // {
pname = "php-${pname}";
passthru = {
updateScript = nix-update-script {};
};
meta = args.meta // {
mainProgram = args.meta.mainProgram or pname;
};
});
mkDerivation = origArgs:
let
args = lib.fix (lib.extends
(_: previousAttrs: {
pname = "php-${previousAttrs.pname}";
passthru = (previousAttrs.passthru or { }) // {
updateScript = nix-update-script { };
};
meta = (previousAttrs.meta or { }) // {
mainProgram = previousAttrs.meta.mainProgram or previousAttrs.pname;
};
})
(if lib.isFunction origArgs then origArgs else (_: origArgs))
);
in
pkgs.stdenv.mkDerivation args;
# Function to build an extension which is shipped as part of the php
# source, based on the php version.