Merge pull request #255731 from etu/php-packages-build-from-source

php.packages.{box,castor}: build from source
This commit is contained in:
Pol Dellaiera 2023-09-24 21:01:43 +02:00 committed by GitHub
commit bbfbf65de0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 56 deletions

View file

@ -1,35 +1,24 @@
{ mkDerivation, fetchurl, makeWrapper, lib, php }:
{ lib, php, fetchFromGitHub }:
let
php.buildComposerProject (finalAttrs: {
pname = "box";
version = "4.3.8";
in
mkDerivation {
inherit pname version;
src = fetchurl {
url = "https://github.com/box-project/box/releases/download/${version}/box.phar";
sha256 = "sha256-g9Y92yTsyXU4NWuQwyB3PRrKJxLRSBO9J77jumXPOxg=";
src = fetchFromGitHub {
owner = "box-project";
repo = "box";
rev = finalAttrs.version;
hash = "sha256-v1J84nqaX36DrLLH5kld+8NIymqtt5/5nJWJNCBVFRE=";
};
dontUnpack = true;
vendorHash = "sha256-LWggAUBMKljxa7HNdJMqOD/sx3IWCOQSqbYEnGntjN0=";
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
install -D $src $out/libexec/box/box.phar
makeWrapper ${php}/bin/php $out/bin/box \
--add-flags "-d phar.readonly=0 $out/libexec/box/box.phar"
runHook postInstall
'';
meta = with lib; {
changelog = "https://github.com/box-project/box/releases/tag/${version}";
meta = {
changelog = "https://github.com/box-project/box/releases/tag/${finalAttrs.version}";
description = "An application for building and managing Phars";
license = licenses.mit;
license = lib.licenses.mit;
homepage = "https://github.com/box-project/box";
maintainers = with maintainers; [ ] ++ teams.php.members;
maintainers = lib.teams.php.members;
mainProgram = "box";
};
}
})

View file

@ -1,60 +1,50 @@
{ lib
, stdenv
, fetchurl
, makeBinaryWrapper
, fetchFromGitHub
, installShellFiles
, php
, nix-update-script
, testers
, castor
}:
stdenv.mkDerivation (finalAttrs: {
php.buildComposerProject (finalAttrs: {
pname = "castor";
version = "0.8.0";
src = fetchurl {
url = "https://github.com/jolicode/castor/releases/download/v${finalAttrs.version}/castor.linux-amd64.phar";
hash = "sha256-0lnn4mS1/DgUoRoMFvCjwQ0j9CX9XWlskbtX9roFCfc=";
src = fetchFromGitHub {
owner = "jolicode";
repo = "castor";
rev = "v${finalAttrs.version}";
hash = "sha256-rJz4BY74BI8gyT4ZlABc4PA+SCsd8guM0m2MTej350g=";
};
dontUnpack = true;
vendorHash = "sha256-Jh4mNNYEM9sy0Dp+dZtD+xrMICjAuspe9D9BDXcfUPM=";
nativeBuildInputs = [ makeBinaryWrapper installShellFiles ];
nativeBuildInputs = [ installShellFiles ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
install -D $src $out/libexec/castor/castor.phar
makeWrapper ${php}/bin/php $out/bin/castor \
--add-flags "$out/libexec/castor/castor.phar"
runHook postInstall
'';
# castor requires to be initialized to generate completion files
# install shell completions
postInstall = ''
echo "yes" | ${php}/bin/php $src
echo "yes" | ${php}/bin/php $out/share/php/castor/bin/castor
installShellCompletion --cmd castor \
--bash <($out/bin/castor completion bash) \
--fish <($out/bin/castor completion fish) \
--zsh <($out/bin/castor completion zsh)
--bash <(${php}/bin/php $out/share/php/castor/bin/castor completion bash) \
--fish <(${php}/bin/php $out/share/php/castor/bin/castor completion fish) \
--zsh <(${php}/bin/php $out/share/php/castor/bin/castor completion zsh)
'';
passthru = {
updateScript = nix-update-script { };
tests.version = testers.testVersion {
inherit (finalAttrs) version;
package = castor;
command = "castor --version";
package = php.packages.castor;
version = "v${finalAttrs.version}";
};
};
meta = with lib; {
meta = {
changelog = "https://github.com/jolicode/castor/blob/v${finalAttrs.version}/CHANGELOG.md";
description = "DX oriented task runner and command launcher built with PHP";
homepage = "https://github.com/jolicode/castor";
changelog = "https://github.com/jolicode/castor/blob/v${finalAttrs.version}/CHANGELOG.md";
license = licenses.mit;
maintainers = with maintainers; [ gaelreyrol ];
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ gaelreyrol ];
mainProgram = "castor";
};
})