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, fetchurl, makeWrapper, lib, php }:
mkDerivation rec { mkDerivation (finalAttrs: {
pname = "grumphp"; pname = "grumphp";
version = "1.15.0"; version = "1.15.0";
src = fetchurl { 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="; sha256 = "sha256-EqzJb7DYZb7PnebErLVI/EZLxj0m26cniZlsu1feif0=";
}; };
@ -16,17 +16,17 @@ mkDerivation rec {
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out/bin 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 \ makeWrapper ${php}/bin/php $out/bin/grumphp \
--add-flags "$out/libexec/${pname}/grumphp.phar" --add-flags "$out/libexec/grumphp/grumphp.phar"
runHook postInstall runHook postInstall
''; '';
meta = with lib; { 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"; description = "A PHP code-quality tool";
homepage = "https://github.com/phpro/grumphp"; homepage = "https://github.com/phpro/grumphp";
license = licenses.mit; license = licenses.mit;
maintainers = teams.php.members; 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 # Wrap mkDerivation to prepend pname with "php-" to make names consistent
# with how buildPecl does it and make the file easier to overview. # with how buildPecl does it and make the file easier to overview.
mkDerivation = { pname, ... }@args: pkgs.stdenv.mkDerivation (args // { mkDerivation = origArgs:
pname = "php-${pname}"; let
passthru = { args = lib.fix (lib.extends
updateScript = nix-update-script {}; (_: previousAttrs: {
}; pname = "php-${previousAttrs.pname}";
meta = args.meta // { passthru = (previousAttrs.passthru or { }) // {
mainProgram = args.meta.mainProgram or pname; 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 # Function to build an extension which is shipped as part of the php
# source, based on the php version. # source, based on the php version.