mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-29 01:14:09 +03:00
php: split build into phases (easier to override)
This commit is contained in:
parent
a7ca27492c
commit
6181050f32
@ -4,7 +4,7 @@
|
|||||||
build = {
|
build = {
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
stdenv,
|
stdenvNoCC,
|
||||||
# dream2nix inputs
|
# dream2nix inputs
|
||||||
externals,
|
externals,
|
||||||
callPackageDream,
|
callPackageDream,
|
||||||
@ -140,7 +140,7 @@
|
|||||||
then "0.0.0"
|
then "0.0.0"
|
||||||
else version;
|
else version;
|
||||||
|
|
||||||
pkg = stdenv.mkDerivation rec {
|
pkg = stdenvNoCC.mkDerivation rec {
|
||||||
pname = l.strings.sanitizeDerivationName name;
|
pname = l.strings.sanitizeDerivationName name;
|
||||||
inherit version;
|
inherit version;
|
||||||
|
|
||||||
@ -161,19 +161,24 @@
|
|||||||
inherit repositoriesString dependenciesString;
|
inherit repositoriesString dependenciesString;
|
||||||
passAsFile = ["repositoriesString" "dependenciesString"];
|
passAsFile = ["repositoriesString" "dependenciesString"];
|
||||||
|
|
||||||
dontConfigure = true;
|
unpackPhase = ''
|
||||||
buildPhase = ''
|
runHook preUnpack
|
||||||
# copy source
|
|
||||||
PKG_OUT=$out/lib/vendor/${name}
|
|
||||||
mkdir -p $PKG_OUT
|
|
||||||
cp -r * $PKG_OUT
|
|
||||||
|
|
||||||
pushd $PKG_OUT
|
mkdir -p $out/lib/vendor/${name}
|
||||||
|
cd $out/lib/vendor/${name}
|
||||||
|
|
||||||
if [ ! -f composer.json ]
|
cp -r ${src}/* .
|
||||||
then
|
chmod -R +w .
|
||||||
|
|
||||||
|
runHook postUnpack
|
||||||
|
'';
|
||||||
|
patchPhase = ''
|
||||||
|
runHook prePatch
|
||||||
|
|
||||||
|
if [ ! -f composer.json ]; then
|
||||||
echo "{}" > composer.json
|
echo "{}" > composer.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp composer.json composer.json.orig
|
cp composer.json composer.json.orig
|
||||||
|
|
||||||
# fixup composer.json
|
# fixup composer.json
|
||||||
@ -183,6 +188,11 @@
|
|||||||
(.extra.patches = {})" \
|
(.extra.patches = {})" \
|
||||||
composer.json | sponge composer.json
|
composer.json | sponge composer.json
|
||||||
|
|
||||||
|
runHook postPatch
|
||||||
|
'';
|
||||||
|
configurePhase = ''
|
||||||
|
runHook preConfigure
|
||||||
|
|
||||||
# disable packagist, set path repositories
|
# disable packagist, set path repositories
|
||||||
jq \
|
jq \
|
||||||
--slurpfile repositories $repositoriesStringPath \
|
--slurpfile repositories $repositoriesStringPath \
|
||||||
@ -192,29 +202,35 @@
|
|||||||
(.\"require-dev\" = {})" \
|
(.\"require-dev\" = {})" \
|
||||||
composer.json | sponge composer.json
|
composer.json | sponge composer.json
|
||||||
|
|
||||||
|
runHook postConfigure
|
||||||
|
'';
|
||||||
|
composerInstallFlags = "--no-scripts --no-plugins";
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
# remove composer.lock if exists
|
# remove composer.lock if exists
|
||||||
rm -f composer.lock
|
rm -f composer.lock
|
||||||
|
|
||||||
# build
|
# build
|
||||||
composer install --no-scripts
|
composer install $composerInstallFlags
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
|
||||||
rm -rfv vendor/*/*/vendor
|
rm -rfv vendor/*/*/vendor
|
||||||
|
|
||||||
popd
|
|
||||||
'';
|
'';
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
pushd $PKG_OUT
|
runHook preInstall
|
||||||
|
|
||||||
BINS=$(jq -rcM "(.bin // [])[]" composer.json)
|
BINS=$(jq -rcM "(.bin // [])[]" composer.json)
|
||||||
for bin in $BINS
|
for bin in $BINS
|
||||||
do
|
do
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
pushd $out/bin
|
pushd $out/bin
|
||||||
ln -s $PKG_OUT/$bin
|
ln -s $out/lib/vendor/${name}/$bin
|
||||||
popd
|
popd
|
||||||
done
|
done
|
||||||
|
|
||||||
popd
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.devShell = import ./devShell.nix {
|
passthru.devShell = import ./devShell.nix {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
build = {
|
build = {
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
stdenv,
|
stdenvNoCC,
|
||||||
# dream2nix inputs
|
# dream2nix inputs
|
||||||
externals,
|
externals,
|
||||||
callPackageDream,
|
callPackageDream,
|
||||||
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
# Unpack dependency
|
# Unpack dependency
|
||||||
cleanDependency = name: version:
|
cleanDependency = name: version:
|
||||||
stdenv.mkDerivation rec {
|
stdenvNoCC.mkDerivation rec {
|
||||||
pname = "${l.strings.sanitizeDerivationName name}-source";
|
pname = "${l.strings.sanitizeDerivationName name}-source";
|
||||||
inherit version;
|
inherit version;
|
||||||
versionString =
|
versionString =
|
||||||
@ -140,7 +140,7 @@
|
|||||||
then "0.0.0"
|
then "0.0.0"
|
||||||
else version;
|
else version;
|
||||||
|
|
||||||
pkg = stdenv.mkDerivation rec {
|
pkg = stdenvNoCC.mkDerivation rec {
|
||||||
pname = l.strings.sanitizeDerivationName name;
|
pname = l.strings.sanitizeDerivationName name;
|
||||||
inherit version;
|
inherit version;
|
||||||
|
|
||||||
@ -158,19 +158,24 @@
|
|||||||
inherit repositoriesString dependenciesString;
|
inherit repositoriesString dependenciesString;
|
||||||
passAsFile = ["repositoriesString" "dependenciesString"];
|
passAsFile = ["repositoriesString" "dependenciesString"];
|
||||||
|
|
||||||
dontConfigure = true;
|
unpackPhase = ''
|
||||||
buildPhase = ''
|
runHook preUnpack
|
||||||
# copy source
|
|
||||||
PKG_OUT=$out/lib/vendor/${name}
|
|
||||||
mkdir -p $PKG_OUT
|
|
||||||
cp -r * $PKG_OUT
|
|
||||||
|
|
||||||
pushd $PKG_OUT
|
mkdir -p $out/lib/vendor/${name}
|
||||||
|
cd $out/lib/vendor/${name}
|
||||||
|
|
||||||
if [ ! -f composer.json ]
|
cp -r ${src}/* .
|
||||||
then
|
chmod -R +w .
|
||||||
|
|
||||||
|
runHook postUnpack
|
||||||
|
'';
|
||||||
|
patchPhase = ''
|
||||||
|
runHook prePatch
|
||||||
|
|
||||||
|
if [ ! -f composer.json ]; then
|
||||||
echo "{}" > composer.json
|
echo "{}" > composer.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp composer.json composer.json.orig
|
cp composer.json composer.json.orig
|
||||||
|
|
||||||
# fixup composer.json
|
# fixup composer.json
|
||||||
@ -180,6 +185,11 @@
|
|||||||
(.extra.patches = {})" \
|
(.extra.patches = {})" \
|
||||||
composer.json | sponge composer.json
|
composer.json | sponge composer.json
|
||||||
|
|
||||||
|
runHook postPatch
|
||||||
|
'';
|
||||||
|
configurePhase = ''
|
||||||
|
runHook preConfigure
|
||||||
|
|
||||||
# disable packagist, set path repositories
|
# disable packagist, set path repositories
|
||||||
jq \
|
jq \
|
||||||
--slurpfile repositories $repositoriesStringPath \
|
--slurpfile repositories $repositoriesStringPath \
|
||||||
@ -189,27 +199,33 @@
|
|||||||
(.\"require-dev\" = {})" \
|
(.\"require-dev\" = {})" \
|
||||||
composer.json | sponge composer.json
|
composer.json | sponge composer.json
|
||||||
|
|
||||||
|
runHook postConfigure
|
||||||
|
'';
|
||||||
|
composerInstallFlags = "--no-scripts --no-plugins";
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
# remove composer.lock if exists
|
# remove composer.lock if exists
|
||||||
rm -f composer.lock
|
rm -f composer.lock
|
||||||
|
|
||||||
# build
|
# build
|
||||||
composer install --no-scripts
|
composer install $composerInstallFlags
|
||||||
|
|
||||||
popd
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
pushd $PKG_OUT
|
runHook preInstall
|
||||||
|
|
||||||
BINS=$(jq -rcM "(.bin // [])[]" composer.json)
|
BINS=$(jq -rcM "(.bin // [])[]" composer.json)
|
||||||
for bin in $BINS
|
for bin in $BINS
|
||||||
do
|
do
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
pushd $out/bin
|
pushd $out/bin
|
||||||
ln -s $PKG_OUT/$bin
|
ln -s $out/lib/vendor/${name}/$bin
|
||||||
popd
|
popd
|
||||||
done
|
done
|
||||||
|
|
||||||
popd
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.devShell = import ./devShell.nix {
|
passthru.devShell = import ./devShell.nix {
|
||||||
|
Loading…
Reference in New Issue
Block a user