php: builders passAsFile repositories,dependencies

This commit is contained in:
Martin Toman 2022-09-20 12:32:28 -07:00
parent 7a2ff69fb3
commit 4f8e284b37
2 changed files with 10 additions and 26 deletions

View File

@ -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 <<EOF >> $out/repositories.json
${repositoriesString}
EOF
cat <<EOF >> $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

View File

@ -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 <<EOF > $out/repositories.json
${repositoriesString}
EOF
cat <<EOF > $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 = ''