From 4f8e284b37e11f1ca68ae317b77376d55f099931 Mon Sep 17 00:00:00 2001 From: Martin Toman Date: Tue, 20 Sep 2022 12:32:28 -0700 Subject: [PATCH] php: builders passAsFile repositories,dependencies --- .../php/builders/granular-php/default.nix | 18 +++++------------- .../php/builders/simple-php/default.nix | 18 +++++------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/subsystems/php/builders/granular-php/default.nix b/src/subsystems/php/builders/granular-php/default.nix index c01c78f6..f53f771f 100644 --- a/src/subsystems/php/builders/granular-php/default.nix +++ b/src/subsystems/php/builders/granular-php/default.nix @@ -140,7 +140,6 @@ inherit version; src = getSource name version; - nativeBuildInputs = with pkgs; [ jq composer @@ -153,6 +152,9 @@ ++ map (dep: allPackages."${dep.name}"."${dep.version}") dependencies; + inherit repositoriesString dependenciesString; + passAsFile = ["repositoriesString" "dependenciesString"]; + dontConfigure = true; buildPhase = '' # copy source @@ -173,16 +175,9 @@ # disable packagist, set path repositories mv composer.json composer.json.orig - cat <> $out/repositories.json - ${repositoriesString} - EOF - cat <> $out/dependencies.json - ${dependenciesString} - EOF - jq \ - --slurpfile repositories $out/repositories.json \ - --slurpfile dependencies $out/dependencies.json \ + --slurpfile repositories $repositoriesStringPath \ + --slurpfile dependencies $dependenciesStringPath \ "(.repositories = \$repositories[0]) | \ (.require = \$dependencies[0]) | \ (.\"require-dev\" = {}) | \ @@ -194,10 +189,7 @@ rm -rfv vendor/*/*/vendor - # cleanup popd - rm $out/repositories.json - rm $out/dependencies.json ''; installPhase = '' pushd $PKG_OUT diff --git a/src/subsystems/php/builders/simple-php/default.nix b/src/subsystems/php/builders/simple-php/default.nix index bb45cfd7..713e8ed9 100644 --- a/src/subsystems/php/builders/simple-php/default.nix +++ b/src/subsystems/php/builders/simple-php/default.nix @@ -139,7 +139,6 @@ inherit version; src = getSource name version; - nativeBuildInputs = with pkgs; [ jq composer @@ -149,6 +148,9 @@ composer ]; + inherit repositoriesString dependenciesString; + passAsFile = ["repositoriesString" "dependenciesString"]; + dontConfigure = true; buildPhase = '' # copy source @@ -163,16 +165,9 @@ # disable packagist, set path repositories mv composer.json composer.json.orig - cat < $out/repositories.json - ${repositoriesString} - EOF - cat < $out/dependencies.json - ${dependenciesString} - EOF - jq \ - --slurpfile repositories $out/repositories.json \ - --slurpfile dependencies $out/dependencies.json \ + --slurpfile repositories $repositoriesStringPath \ + --slurpfile dependencies $dependenciesStringPath \ "(.repositories = \$repositories[0]) | \ (.require = \$dependencies[0]) | \ (.\"require-dev\" = {}) | \ @@ -182,9 +177,6 @@ # build composer install --no-scripts - # cleanup - rm $out/repositories.json - rm $out/dependencies.json popd ''; installPhase = ''