Fix the php packaging for the latest nixpkgs revision

Nixpkgs has dropped PHP 7.2. Updating to PHP 7.4 should be painless as
our usage of PHP is very limited.
This commit is contained in:
Andreas Rammhold 2021-05-16 19:05:52 +02:00 committed by Cole Helbling
parent 0120549043
commit de74c9e88c
5 changed files with 327 additions and 81 deletions

View file

@ -1,41 +1,9 @@
# This file originates from composer2nix
{ stdenv, lib, writeTextFile, fetchurl, php, unzip }:
{ stdenv, lib, writeTextFile, fetchurl, php, unzip, phpPackages }:
let
composer = stdenv.mkDerivation {
name = "composer-1.6.5";
src = fetchurl {
url = https://github.com/composer/composer/releases/download/1.6.5/composer.phar;
sha256 = "07xkpg9y1dd4s33y3cbf7r5fphpgc39mpm066a8m9y4ffsf539f0";
};
buildInputs = [ php ];
# We must wrap the composer.phar because of the impure shebang.
# We cannot use patchShebangs because the executable verifies its own integrity and will detect that somebody has tampered with it.
buildCommand = ''
# Copy phar file
mkdir -p $out/share/php
cp $src $out/share/php/composer.phar
chmod 755 $out/share/php/composer.phar
# Create wrapper executable
mkdir -p $out/bin
cat > $out/bin/composer <<EOF
#! ${stdenv.shell} -e
exec ${php}/bin/php $out/share/php/composer.phar "\$@"
EOF
chmod +x $out/bin/composer
'';
meta = {
description = "Dependency Manager for PHP";
#license = stdenv.licenses.mit;
maintainers = [ lib.maintainers.sander ];
platforms = lib.platforms.unix;
};
};
inherit (phpPackages) composer;
buildZipPackage = { name, src }:
stdenv.mkDerivation {
inherit name src;
@ -60,6 +28,7 @@ let
, removeComposerArtifacts ? false
, postInstall ? ""
, noDev ? false
, composerExtraArgs ? ""
, unpackPhase ? "true"
, buildPhase ? "true"
, ...}@args:
@ -206,7 +175,7 @@ let
# Reconstruct the installed.json file from the lock file
mkdir -p vendor/composer
${reconstructInstalled} composer.lock > vendor/composer/installed.json
${php}/bin/php ${reconstructInstalled} composer.lock > vendor/composer/installed.json
# Copy or symlink the provided dependencies
cd vendor
@ -217,14 +186,14 @@ let
# Reconstruct autoload scripts
# We use the optimize feature because Nix packages cannot change after they have been built
# Using the dynamic loader for a Nix package is useless since there is nothing to dynamically reload.
composer dump-autoload --optimize ${lib.optionalString noDev "--no-dev"}
composer dump-autoload --optimize ${lib.optionalString noDev "--no-dev"} ${composerExtraArgs}
# Run the install step as a validation to confirm that everything works out as expected
composer install --optimize-autoloader ${lib.optionalString noDev "--no-dev"}
composer install --optimize-autoloader ${lib.optionalString noDev "--no-dev"} ${composerExtraArgs}
${lib.optionalString executable ''
# Reconstruct the bin/ folder if we deploy an executable project
${constructBin} composer.json
${php}/bin/php ${constructBin} composer.json
ln -s $(pwd)/vendor/bin $out/bin
''}

View file

@ -1,5 +1,5 @@
{
"name": "ofborg-webhook",
"name": "nixos/ofborg-webhook",
"require": {
"php-amqplib/php-amqplib": ">=2.6.1",
"svanderburg/composer2nix": ">=0.0.3"

309
php/composer.lock generated
View file

@ -1,46 +1,164 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "81858eba648031903f09c76e5d8e23cd",
"content-hash": "6bf65db2920cc5f1530dd0c9d42fdaaa",
"packages": [
{
"name": "php-amqplib/php-amqplib",
"version": "v2.7.2",
"name": "paragonie/constant_time_encoding",
"version": "v2.4.0",
"source": {
"type": "git",
"url": "https://github.com/php-amqplib/php-amqplib.git",
"reference": "dfd3694a86f1a7394d3693485259d4074a6ec79b"
"url": "https://github.com/paragonie/constant_time_encoding.git",
"reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/dfd3694a86f1a7394d3693485259d4074a6ec79b",
"reference": "dfd3694a86f1a7394d3693485259d4074a6ec79b",
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c",
"reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c",
"shasum": ""
},
"require": {
"php": "^7|^8"
},
"require-dev": {
"phpunit/phpunit": "^6|^7|^8|^9",
"vimeo/psalm": "^1|^2|^3|^4"
},
"type": "library",
"autoload": {
"psr-4": {
"ParagonIE\\ConstantTime\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com",
"role": "Maintainer"
},
{
"name": "Steve 'Sc00bz' Thomas",
"email": "steve@tobtu.com",
"homepage": "https://www.tobtu.com",
"role": "Original Developer"
}
],
"description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)",
"keywords": [
"base16",
"base32",
"base32_decode",
"base32_encode",
"base64",
"base64_decode",
"base64_encode",
"bin2hex",
"encoding",
"hex",
"hex2bin",
"rfc4648"
],
"support": {
"email": "info@paragonie.com",
"issues": "https://github.com/paragonie/constant_time_encoding/issues",
"source": "https://github.com/paragonie/constant_time_encoding"
},
"time": "2020-12-06T15:14:20+00:00"
},
{
"name": "paragonie/random_compat",
"version": "v9.99.100",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a",
"shasum": ""
},
"require": {
"php": ">= 7"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*",
"vimeo/psalm": "^1"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"polyfill",
"pseudorandom",
"random"
],
"support": {
"email": "info@paragonie.com",
"issues": "https://github.com/paragonie/random_compat/issues",
"source": "https://github.com/paragonie/random_compat"
},
"time": "2020-10-15T08:29:30+00:00"
},
{
"name": "php-amqplib/php-amqplib",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-amqplib/php-amqplib.git",
"reference": "c0a8eade209b7e43d6a405303d8de716dfd02749"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/c0a8eade209b7e43d6a405303d8de716dfd02749",
"reference": "c0a8eade209b7e43d6a405303d8de716dfd02749",
"shasum": ""
},
"require": {
"ext-bcmath": "*",
"ext-mbstring": "*",
"php": ">=5.3.0"
"ext-sockets": "*",
"php": "^7.0|~8.0.0",
"phpseclib/phpseclib": "^2.0|^3.0"
},
"conflict": {
"php": "7.4.0 - 7.4.1"
},
"replace": {
"videlalvaro/php-amqplib": "self.version"
},
"require-dev": {
"phpdocumentor/phpdocumentor": "^2.9",
"phpunit/phpunit": "^4.8",
"scrutinizer/ocular": "^1.1",
"squizlabs/php_codesniffer": "^2.5"
},
"suggest": {
"ext-sockets": "Use AMQPSocketConnection"
"ext-curl": "*",
"nategood/httpful": "^0.2.20",
"phpunit/phpunit": "^6.5|^7.0|^9.5",
"squizlabs/php_codesniffer": "^3.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
@ -58,13 +176,18 @@
"role": "Original Maintainer"
},
{
"name": "John Kelly",
"email": "johnmkelly86@gmail.com",
"name": "Raúl Araya",
"email": "nubeiro@gmail.com",
"role": "Maintainer"
},
{
"name": "Raúl Araya",
"email": "nubeiro@gmail.com",
"name": "Luke Bakken",
"email": "luke@bakken.io",
"role": "Maintainer"
},
{
"name": "Ramūnas Dronga",
"email": "github@ramuno.lt",
"role": "Maintainer"
}
],
@ -75,20 +198,135 @@
"queue",
"rabbitmq"
],
"time": "2018-02-11T19:28:00+00:00"
"support": {
"issues": "https://github.com/php-amqplib/php-amqplib/issues",
"source": "https://github.com/php-amqplib/php-amqplib/tree/v3.0.0"
},
"time": "2021-03-16T15:00:23+00:00"
},
{
"name": "svanderburg/composer2nix",
"version": "v0.0.3",
"name": "phpseclib/phpseclib",
"version": "3.0.8",
"source": {
"type": "git",
"url": "https://github.com/svanderburg/composer2nix.git",
"reference": "2fb157acaf0ecbe34436195c694637396f7258a6"
"url": "https://github.com/phpseclib/phpseclib.git",
"reference": "d9615a6fb970d9933866ca8b4036ec3407b020b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/svanderburg/composer2nix/zipball/2fb157acaf0ecbe34436195c694637396f7258a6",
"reference": "2fb157acaf0ecbe34436195c694637396f7258a6",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d9615a6fb970d9933866ca8b4036ec3407b020b6",
"reference": "d9615a6fb970d9933866ca8b4036ec3407b020b6",
"shasum": ""
},
"require": {
"paragonie/constant_time_encoding": "^1|^2",
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
"php": ">=5.6.1"
},
"require-dev": {
"phing/phing": "~2.7",
"phpunit/phpunit": "^5.7|^6.0|^9.4",
"squizlabs/php_codesniffer": "~2.0"
},
"suggest": {
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
},
"type": "library",
"autoload": {
"files": [
"phpseclib/bootstrap.php"
],
"psr-4": {
"phpseclib3\\": "phpseclib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jim Wigginton",
"email": "terrafrost@php.net",
"role": "Lead Developer"
},
{
"name": "Patrick Monnerat",
"email": "pm@datasphere.ch",
"role": "Developer"
},
{
"name": "Andreas Fischer",
"email": "bantu@phpbb.com",
"role": "Developer"
},
{
"name": "Hans-Jürgen Petrich",
"email": "petrich@tronic-media.com",
"role": "Developer"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"role": "Developer"
}
],
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
"homepage": "http://phpseclib.sourceforge.net",
"keywords": [
"BigInteger",
"aes",
"asn.1",
"asn1",
"blowfish",
"crypto",
"cryptography",
"encryption",
"rsa",
"security",
"sftp",
"signature",
"signing",
"ssh",
"twofish",
"x.509",
"x509"
],
"support": {
"issues": "https://github.com/phpseclib/phpseclib/issues",
"source": "https://github.com/phpseclib/phpseclib/tree/3.0.8"
},
"funding": [
{
"url": "https://github.com/terrafrost",
"type": "github"
},
{
"url": "https://www.patreon.com/phpseclib",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib",
"type": "tidelift"
}
],
"time": "2021-04-19T03:20:48+00:00"
},
{
"name": "svanderburg/composer2nix",
"version": "v0.0.5",
"source": {
"type": "git",
"url": "https://github.com/svanderburg/composer2nix.git",
"reference": "9983c6fafb277f6b305edf232c2690d6d28ec092"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/svanderburg/composer2nix/zipball/9983c6fafb277f6b305edf232c2690d6d28ec092",
"reference": "9983c6fafb277f6b305edf232c2690d6d28ec092",
"shasum": ""
},
"require": {
@ -118,7 +356,11 @@
}
],
"description": "Generate Nix expressions to build PHP composer packages",
"time": "2018-06-29T20:58:30+00:00"
"support": {
"issues": "https://github.com/svanderburg/composer2nix/issues",
"source": "https://github.com/svanderburg/composer2nix/tree/v0.0.5"
},
"time": "2021-02-27T12:58:49+00:00"
},
{
"name": "svanderburg/pndp",
@ -158,6 +400,10 @@
}
],
"description": "PNDP: An internal DSL for Nix in PHP",
"support": {
"issues": "https://github.com/svanderburg/pndp/issues",
"source": "https://github.com/svanderburg/pndp/tree/v0.0.2"
},
"time": "2017-10-22T12:43:22+00:00"
}
],
@ -168,5 +414,6 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
"platform-dev": [],
"plugin-api-version": "2.0.0"
}

View file

@ -4,8 +4,8 @@
let
composerEnv = import ./composer-env.nix {
inherit (pkgs) stdenv lib writeTextFile fetchurl unzip;
php = pkgs.php72;
inherit (pkgs) stdenv lib writeTextFile fetchurl unzip phpPackages;
php = pkgs.php74;
};
in
import ./php-packages.nix {

View file

@ -2,23 +2,53 @@
let
packages = {
"paragonie/constant_time_encoding" = {
targetDir = "";
src = composerEnv.buildZipPackage {
name = "paragonie-constant_time_encoding-f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c";
src = fetchurl {
url = "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c";
sha256 = "1r1xj3j7s5mskw5gh3ars4dfhvcn7d252gdqgpif80026kj5fvrp";
};
};
};
"paragonie/random_compat" = {
targetDir = "";
src = composerEnv.buildZipPackage {
name = "paragonie-random_compat-996434e5492cb4c3edcb9168db6fbb1359ef965a";
src = fetchurl {
url = "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a";
sha256 = "0ky7lal59dihf969r1k3pb96ql8zzdc5062jdbg69j6rj0scgkyx";
};
};
};
"php-amqplib/php-amqplib" = {
targetDir = "";
src = composerEnv.buildZipPackage {
name = "php-amqplib-php-amqplib-dfd3694a86f1a7394d3693485259d4074a6ec79b";
name = "php-amqplib-php-amqplib-c0a8eade209b7e43d6a405303d8de716dfd02749";
src = fetchurl {
url = https://api.github.com/repos/php-amqplib/php-amqplib/zipball/dfd3694a86f1a7394d3693485259d4074a6ec79b;
sha256 = "1dlxgdnhy8xyx8xbp1glc7igksvsqyc3yaq76irhy09djij013ip";
url = "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/c0a8eade209b7e43d6a405303d8de716dfd02749";
sha256 = "1lck5hpraxi4w3831lfzz6l7c82118b56aghdz0dr4r92366j3xf";
};
};
};
"phpseclib/phpseclib" = {
targetDir = "";
src = composerEnv.buildZipPackage {
name = "phpseclib-phpseclib-d9615a6fb970d9933866ca8b4036ec3407b020b6";
src = fetchurl {
url = "https://api.github.com/repos/phpseclib/phpseclib/zipball/d9615a6fb970d9933866ca8b4036ec3407b020b6";
sha256 = "1xyymb11qdx8rn6c9bx9js8yq405bmjq8ar8phvpji9a3fdd6z4v";
};
};
};
"svanderburg/composer2nix" = {
targetDir = "";
src = composerEnv.buildZipPackage {
name = "svanderburg-composer2nix-2fb157acaf0ecbe34436195c694637396f7258a6";
name = "svanderburg-composer2nix-9983c6fafb277f6b305edf232c2690d6d28ec092";
src = fetchurl {
url = https://api.github.com/repos/svanderburg/composer2nix/zipball/2fb157acaf0ecbe34436195c694637396f7258a6;
sha256 = "01i3kxgx7pcmxafclp8ib08nib1xh6nvr5sbl6y38rw19xhnwa0m";
url = "https://api.github.com/repos/svanderburg/composer2nix/zipball/9983c6fafb277f6b305edf232c2690d6d28ec092";
sha256 = "1s1gv2b4y9pjv56mif8fgch56sssdmrcwb1gk3gksxc0jq2w2zbv";
};
};
};
@ -27,7 +57,7 @@ let
src = composerEnv.buildZipPackage {
name = "svanderburg-pndp-4bfe9c4120c23354ab8dc295957dc3009a39bff0";
src = fetchurl {
url = https://api.github.com/repos/svanderburg/pndp/zipball/4bfe9c4120c23354ab8dc295957dc3009a39bff0;
url = "https://api.github.com/repos/svanderburg/pndp/zipball/4bfe9c4120c23354ab8dc295957dc3009a39bff0";
sha256 = "0n2vwpwshv16bhb7a6j95m664zh4lpfa7dqmcyhmn89nxpgvg91y";
};
};
@ -37,7 +67,7 @@ let
in
composerEnv.buildPackage {
inherit packages devPackages noDev;
name = "ofborg-webhook";
name = "nixos-ofborg-webhook";
src = ./.;
executable = false;
symlinkDependencies = false;