From a9911c193364178b5e723c9262cdb95c3bcf6f1c Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Mon, 30 Sep 2019 22:29:56 +0200 Subject: [PATCH] Use composer from nixpkgs The composer pinned here, was outdated and broken with PHP 7.3, the default in NixOS 19.09 --- default.nix | 4 +-- src/Composer2Nix/Composer.php | 2 +- .../Expressions/CompositionExpression.php | 3 +- src/Composer2Nix/composer-env.nix | 36 ++----------------- 4 files changed, 7 insertions(+), 38 deletions(-) diff --git a/default.nix b/default.nix index 28b6cae..264f73c 100644 --- a/default.nix +++ b/default.nix @@ -4,10 +4,10 @@ let composerEnv = import ./src/Composer2Nix/composer-env.nix { - inherit (pkgs) stdenv writeTextFile fetchurl php unzip; + inherit (pkgs) stdenv writeTextFile fetchurl php unzip phpPackages; }; in import ./php-packages.nix { inherit composerEnv noDev; inherit (pkgs) fetchurl fetchgit fetchhg fetchsvn; -} \ No newline at end of file +} diff --git a/src/Composer2Nix/Composer.php b/src/Composer2Nix/Composer.php index d9a12e1..c576841 100644 --- a/src/Composer2Nix/Composer.php +++ b/src/Composer2Nix/Composer.php @@ -64,7 +64,7 @@ class Composer else if($preferredInstall == "dist") $params .= " --prefer-dist"; - $composerPath = shell_exec("nix-build --no-out-link -E 'let pkgs = import {}; 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 {}; composerEnv = import ".__DIR__."/composer-env.nix { inherit (pkgs) stdenv writeTextFile fetchurl php unzip phpPackages; }; in composerEnv.composer'"); if($composerPath === false) throw new Exception("Cannot deploy the composer Nix package!"); diff --git a/src/Composer2Nix/Expressions/CompositionExpression.php b/src/Composer2Nix/Expressions/CompositionExpression.php index ea18390..0bce4d2 100644 --- a/src/Composer2Nix/Expressions/CompositionExpression.php +++ b/src/Composer2Nix/Expressions/CompositionExpression.php @@ -81,7 +81,8 @@ class CompositionExpression extends NixASTNode "writeTextFile" => new NixInherit("pkgs"), "fetchurl" => 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( "composerEnv" => new NixInherit(), diff --git a/src/Composer2Nix/composer-env.nix b/src/Composer2Nix/composer-env.nix index 955a359..279b307 100644 --- a/src/Composer2Nix/composer-env.nix +++ b/src/Composer2Nix/composer-env.nix @@ -1,41 +1,9 @@ # This file originates from composer2nix -{ stdenv, writeTextFile, fetchurl, php, unzip }: +{ stdenv, 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 <