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; inherit version;
src = getSource name version; src = getSource name version;
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
jq jq
composer composer
@ -153,6 +152,9 @@
++ map (dep: allPackages."${dep.name}"."${dep.version}") ++ map (dep: allPackages."${dep.name}"."${dep.version}")
dependencies; dependencies;
inherit repositoriesString dependenciesString;
passAsFile = ["repositoriesString" "dependenciesString"];
dontConfigure = true; dontConfigure = true;
buildPhase = '' buildPhase = ''
# copy source # copy source
@ -173,16 +175,9 @@
# disable packagist, set path repositories # disable packagist, set path repositories
mv composer.json composer.json.orig mv composer.json composer.json.orig
cat <<EOF >> $out/repositories.json
${repositoriesString}
EOF
cat <<EOF >> $out/dependencies.json
${dependenciesString}
EOF
jq \ jq \
--slurpfile repositories $out/repositories.json \ --slurpfile repositories $repositoriesStringPath \
--slurpfile dependencies $out/dependencies.json \ --slurpfile dependencies $dependenciesStringPath \
"(.repositories = \$repositories[0]) | \ "(.repositories = \$repositories[0]) | \
(.require = \$dependencies[0]) | \ (.require = \$dependencies[0]) | \
(.\"require-dev\" = {}) | \ (.\"require-dev\" = {}) | \
@ -194,10 +189,7 @@
rm -rfv vendor/*/*/vendor rm -rfv vendor/*/*/vendor
# cleanup
popd popd
rm $out/repositories.json
rm $out/dependencies.json
''; '';
installPhase = '' installPhase = ''
pushd $PKG_OUT pushd $PKG_OUT

View File

@ -139,7 +139,6 @@
inherit version; inherit version;
src = getSource name version; src = getSource name version;
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
jq jq
composer composer
@ -149,6 +148,9 @@
composer composer
]; ];
inherit repositoriesString dependenciesString;
passAsFile = ["repositoriesString" "dependenciesString"];
dontConfigure = true; dontConfigure = true;
buildPhase = '' buildPhase = ''
# copy source # copy source
@ -163,16 +165,9 @@
# disable packagist, set path repositories # disable packagist, set path repositories
mv composer.json composer.json.orig mv composer.json composer.json.orig
cat <<EOF > $out/repositories.json
${repositoriesString}
EOF
cat <<EOF > $out/dependencies.json
${dependenciesString}
EOF
jq \ jq \
--slurpfile repositories $out/repositories.json \ --slurpfile repositories $repositoriesStringPath \
--slurpfile dependencies $out/dependencies.json \ --slurpfile dependencies $dependenciesStringPath \
"(.repositories = \$repositories[0]) | \ "(.repositories = \$repositories[0]) | \
(.require = \$dependencies[0]) | \ (.require = \$dependencies[0]) | \
(.\"require-dev\" = {}) | \ (.\"require-dev\" = {}) | \
@ -182,9 +177,6 @@
# build # build
composer install --no-scripts composer install --no-scripts
# cleanup
rm $out/repositories.json
rm $out/dependencies.json
popd popd
''; '';
installPhase = '' installPhase = ''