2022-03-05 16:20:37 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchurl
|
|
|
|
, formats
|
|
|
|
, installShellFiles
|
|
|
|
, makeWrapper
|
|
|
|
, php
|
|
|
|
}:
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
let
|
2022-03-05 16:20:37 +00:00
|
|
|
version = "2.6.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
completion = fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/wp-cli/wp-cli/v${version}/utils/wp-completion.bash";
|
2022-03-05 16:20:37 +00:00
|
|
|
hash = "sha256-RDygYQzK6NLWrOug7EqnkpuH7Wz1T2Zq/tGNZjoYo5U=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
ini = (formats.ini { }).generate "php.ini" {
|
|
|
|
PHP.memory_limit = -1; # no limit as composer uses a lot of memory
|
|
|
|
Phar."phar.readonly" = "Off";
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "wp-cli";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${pname}-${version}.phar";
|
2022-03-05 16:20:37 +00:00
|
|
|
hash = "sha256-0WZSjKtgvIIpwGcp5wc4OPu6aNaytXRQTLAniDXIeIg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles makeWrapper ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
dir=$out/share/wp-cli
|
|
|
|
install -Dm444 ${src} $dir/wp-cli
|
|
|
|
install -Dm444 ${ini} $dir/php.ini
|
2022-03-05 16:20:37 +00:00
|
|
|
installShellCompletion --bash --name wp ${completion}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
mkdir -p $out/bin
|
2020-04-24 23:36:52 +00:00
|
|
|
makeWrapper ${lib.getBin php}/bin/php $out/bin/wp \
|
|
|
|
--add-flags "-c $dir/php.ini" \
|
2022-03-30 09:31:56 +00:00
|
|
|
--add-flags "-f $dir/wp-cli" \
|
|
|
|
--add-flags "--"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# this is a very basic run test
|
|
|
|
$out/bin/wp --info >/dev/null
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A command line interface for WordPress";
|
|
|
|
homepage = "https://wp-cli.org";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ peterhoeg ];
|
|
|
|
platforms = platforms.all;
|
2022-04-03 18:54:34 +00:00
|
|
|
mainProgram = "wp";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|