Use composer from nixpkgs

The composer pinned here, was outdated and broken with PHP 7.3, the
default in NixOS 19.09
This commit is contained in:
Robin Gloster 2019-09-30 22:29:56 +02:00
parent 2fb157acaf
commit a9911c1933
No known key found for this signature in database
GPG key ID: D5C458DF6DD97EDF
4 changed files with 7 additions and 38 deletions

View file

@ -4,10 +4,10 @@
let let
composerEnv = import ./src/Composer2Nix/composer-env.nix { composerEnv = import ./src/Composer2Nix/composer-env.nix {
inherit (pkgs) stdenv writeTextFile fetchurl php unzip; inherit (pkgs) stdenv writeTextFile fetchurl php unzip phpPackages;
}; };
in in
import ./php-packages.nix { import ./php-packages.nix {
inherit composerEnv noDev; inherit composerEnv noDev;
inherit (pkgs) fetchurl fetchgit fetchhg fetchsvn; inherit (pkgs) fetchurl fetchgit fetchhg fetchsvn;
} }

View file

@ -64,7 +64,7 @@ class Composer
else if($preferredInstall == "dist") else if($preferredInstall == "dist")
$params .= " --prefer-dist"; $params .= " --prefer-dist";
$composerPath = shell_exec("nix-build --no-out-link -E 'let pkgs = import <nixpkgs> {}; composerEnv = import ".__DIR__."/composer-env.nix { inherit (pkgs) stdenv writeTextFile fetchurl php unzip; }; in composerEnv.composer'"); $composerPath = shell_exec("nix-build --no-out-link -E 'let pkgs = import <nixpkgs> {}; composerEnv = import ".__DIR__."/composer-env.nix { inherit (pkgs) stdenv writeTextFile fetchurl php unzip phpPackages; }; in composerEnv.composer'");
if($composerPath === false) if($composerPath === false)
throw new Exception("Cannot deploy the composer Nix package!"); throw new Exception("Cannot deploy the composer Nix package!");

View file

@ -81,7 +81,8 @@ class CompositionExpression extends NixASTNode
"writeTextFile" => new NixInherit("pkgs"), "writeTextFile" => new NixInherit("pkgs"),
"fetchurl" => new NixInherit("pkgs"), "fetchurl" => new NixInherit("pkgs"),
"php" => new NixInherit("pkgs"), "php" => new NixInherit("pkgs"),
"unzip" => new NixInherit("pkgs") "unzip" => new NixInherit("pkgs"),
"phpPackages" => new NixInherit("pkgs")
)) ))
), new NixFunInvocation(new NixImport(new NixFile($this->prefixRelativePath($this->outputFile))), array( ), new NixFunInvocation(new NixImport(new NixFile($this->prefixRelativePath($this->outputFile))), array(
"composerEnv" => new NixInherit(), "composerEnv" => new NixInherit(),

View file

@ -1,41 +1,9 @@
# This file originates from composer2nix # This file originates from composer2nix
{ stdenv, writeTextFile, fetchurl, php, unzip }: { stdenv, writeTextFile, fetchurl, php, unzip, phpPackages }:
let let
composer = stdenv.mkDerivation { inherit (phpPackages) composer;
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 = [ stdenv.lib.maintainers.sander ];
platforms = stdenv.lib.platforms.unix;
};
};
buildZipPackage = { name, src }: buildZipPackage = { name, src }:
stdenv.mkDerivation { stdenv.mkDerivation {
inherit name src; inherit name src;