1{ stdenv, lib, fetchurl, writeScript, writeText, php }:
2
3let
4 name = "wp-cli-${version}";
5 version = "2.0.0";
6
7 src = fetchurl {
8 url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${name}.phar";
9 sha256 = "1s8pv8vdjwiwknpwsxc59l1zxc2np7nrp6bjd0s8jwsrv5fgjzsp";
10 };
11
12 completion = fetchurl {
13 url = "https://raw.githubusercontent.com/wp-cli/wp-cli/v${version}/utils/wp-completion.bash";
14 sha256 = "15d330x6d3fizrm6ckzmdknqg6wjlx5fr87bmkbd5s6a1ihs0g24";
15 };
16
17 bin = writeScript "wp" ''
18 #! ${stdenv.shell}
19
20 set -euo pipefail
21
22 exec ${lib.getBin php}/bin/php \
23 -c ${ini} \
24 -f ${src} -- "$@"
25 '';
26
27 ini = writeText "wp-cli.ini" ''
28 [PHP]
29 memory_limit = -1 ; no limit as composer uses a lot of memory
30
31 [Phar]
32 phar.readonly = Off
33 '';
34
35in stdenv.mkDerivation rec {
36 inherit name version;
37
38 buildCommand = ''
39 install -Dm755 ${bin} $out/bin/wp
40 install -Dm644 ${completion} $out/share/bash-completion/completions/wp
41
42 # this is a very basic run test
43 $out/bin/wp --info
44 '';
45
46 meta = with stdenv.lib; {
47 description = "A command line interface for WordPress";
48 homepage = https://wp-cli.org;
49 license = licenses.mit;
50 maintainers = with maintainers; [ peterhoeg ];
51 platforms = platforms.all;
52 };
53}