2017-08-16 02:39:22 +02:00
|
|
|
{ stdenv, lib, fetchurl, writeScript, writeText, php }:
|
2016-05-22 10:51:48 +02:00
|
|
|
|
|
|
|
let
|
2017-08-16 02:39:22 +02:00
|
|
|
name = "wp-cli-${version}";
|
2018-08-10 08:59:59 +02:00
|
|
|
version = "2.0.0";
|
2016-09-13 12:20:51 +02:00
|
|
|
|
2017-08-16 02:39:22 +02:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${name}.phar";
|
2018-08-10 08:59:59 +02:00
|
|
|
sha256 = "1s8pv8vdjwiwknpwsxc59l1zxc2np7nrp6bjd0s8jwsrv5fgjzsp";
|
2017-08-16 02:39:22 +02:00
|
|
|
};
|
2016-05-22 10:51:48 +02:00
|
|
|
|
2017-01-23 05:35:07 +01:00
|
|
|
completion = fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/wp-cli/wp-cli/v${version}/utils/wp-completion.bash";
|
|
|
|
sha256 = "15d330x6d3fizrm6ckzmdknqg6wjlx5fr87bmkbd5s6a1ihs0g24";
|
|
|
|
};
|
|
|
|
|
2017-08-16 02:39:22 +02:00
|
|
|
bin = writeScript "wp" ''
|
|
|
|
#! ${stdenv.shell}
|
2016-05-22 10:51:48 +02:00
|
|
|
|
2017-08-16 02:39:22 +02:00
|
|
|
set -euo pipefail
|
2016-05-22 10:51:48 +02:00
|
|
|
|
2017-08-16 02:39:22 +02:00
|
|
|
exec ${lib.getBin php}/bin/php \
|
|
|
|
-c ${ini} \
|
|
|
|
-f ${src} -- "$@"
|
|
|
|
'';
|
2016-05-22 10:51:48 +02:00
|
|
|
|
2017-08-16 02:39:22 +02:00
|
|
|
ini = writeText "wp-cli.ini" ''
|
2017-12-27 17:34:51 +01:00
|
|
|
[PHP]
|
2018-02-04 04:50:58 +01:00
|
|
|
memory_limit = -1 ; no limit as composer uses a lot of memory
|
2017-12-27 17:34:51 +01:00
|
|
|
|
2017-01-23 05:35:07 +01:00
|
|
|
[Phar]
|
|
|
|
phar.readonly = Off
|
2017-08-16 02:39:22 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
inherit name version;
|
|
|
|
|
|
|
|
buildCommand = ''
|
2018-08-10 08:59:59 +02:00
|
|
|
install -Dm755 ${bin} $out/bin/wp
|
2017-01-23 05:35:07 +01:00
|
|
|
install -Dm644 ${completion} $out/share/bash-completion/completions/wp
|
2018-01-13 07:02:11 +01:00
|
|
|
|
|
|
|
# this is a very basic run test
|
|
|
|
$out/bin/wp --info
|
2016-05-22 10:51:48 +02:00
|
|
|
'';
|
|
|
|
|
2016-09-13 12:20:51 +02:00
|
|
|
meta = with stdenv.lib; {
|
2016-05-22 10:51:48 +02:00
|
|
|
description = "A command line interface for WordPress";
|
2017-08-16 02:39:22 +02:00
|
|
|
homepage = https://wp-cli.org;
|
|
|
|
license = licenses.mit;
|
2016-09-13 12:20:51 +02:00
|
|
|
maintainers = with maintainers; [ peterhoeg ];
|
2017-08-16 02:39:22 +02:00
|
|
|
platforms = platforms.all;
|
2016-05-22 10:51:48 +02:00
|
|
|
};
|
|
|
|
}
|