wp-cli: use 1 store path instead of 4

This commit is contained in:
Peter Hoeg 2018-08-10 15:15:22 +08:00
parent 656b59e3db
commit 037813906d

@ -1,42 +1,46 @@
{ stdenv, lib, fetchurl, writeScript, writeText, php }:
let
name = "wp-cli-${version}";
version = "2.0.0";
src = fetchurl {
url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${name}.phar";
sha256 = "1s8pv8vdjwiwknpwsxc59l1zxc2np7nrp6bjd0s8jwsrv5fgjzsp";
};
completion = fetchurl {
url = "https://raw.githubusercontent.com/wp-cli/wp-cli/v${version}/utils/wp-completion.bash";
sha256 = "15d330x6d3fizrm6ckzmdknqg6wjlx5fr87bmkbd5s6a1ihs0g24";
};
bin = writeScript "wp" ''
#! ${stdenv.shell}
set -euo pipefail
exec ${lib.getBin php}/bin/php \
-c ${ini} \
-f ${src} -- "$@"
'';
ini = writeText "wp-cli.ini" ''
[PHP]
memory_limit = -1 ; no limit as composer uses a lot of memory
[Phar]
phar.readonly = Off
'';
in stdenv.mkDerivation rec {
inherit name version;
name = "wp-cli-${version}";
inherit version;
src = fetchurl {
url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${name}.phar";
sha256 = "1s8pv8vdjwiwknpwsxc59l1zxc2np7nrp6bjd0s8jwsrv5fgjzsp";
};
buildCommand = ''
install -Dm755 ${bin} $out/bin/wp
dir=$out/share/wp-cli
mkdir -p $out/bin $dir
cat <<_EOF > $out/bin/wp
#!${stdenv.shell}
set -euo pipefail
exec ${lib.getBin php}/bin/php \\
-c $dir/php.ini \\
-f $dir/wp-cli -- "\$@"
_EOF
chmod 0755 $out/bin/wp
cat <<_EOF > $dir/php.ini
[PHP]
memory_limit = -1 ; no limit as composer uses a lot of memory
[Phar]
phar.readonly = Off
_EOF
install -Dm644 ${src} $dir/wp-cli
install -Dm644 ${completion} $out/share/bash-completion/completions/wp
# this is a very basic run test