nixpkgs/pkgs/development/tools/wp-cli/default.nix

50 lines
1.2 KiB
Nix
Raw Normal View History

2017-08-16 00:39:22 +00:00
{ stdenv, lib, fetchurl, writeScript, writeText, php }:
2016-05-22 08:51:48 +00:00
let
2017-08-16 00:39:22 +00:00
name = "wp-cli-${version}";
2017-10-31 15:59:06 +00:00
version = "1.4.0";
2016-09-13 10:20:51 +00:00
2017-08-16 00:39:22 +00:00
src = fetchurl {
url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${name}.phar";
2017-10-31 15:59:06 +00:00
sha256 = "0rav5a6znx81gwaxin1ib10sbfg16bgdnnyv1zn5sjify3f1wpqj";
2017-08-16 00:39:22 +00:00
};
2016-05-22 08:51:48 +00:00
completion = fetchurl {
url = "https://raw.githubusercontent.com/wp-cli/wp-cli/v${version}/utils/wp-completion.bash";
sha256 = "15d330x6d3fizrm6ckzmdknqg6wjlx5fr87bmkbd5s6a1ihs0g24";
};
2017-08-16 00:39:22 +00:00
bin = writeScript "wp" ''
#! ${stdenv.shell}
2016-05-22 08:51:48 +00:00
2017-08-16 00:39:22 +00:00
set -euo pipefail
2016-05-22 08:51:48 +00:00
2017-08-16 00:39:22 +00:00
exec ${lib.getBin php}/bin/php \
-c ${ini} \
-f ${src} -- "$@"
'';
2016-05-22 08:51:48 +00:00
2017-08-16 00:39:22 +00:00
ini = writeText "wp-cli.ini" ''
[Phar]
phar.readonly = Off
2017-08-16 00:39:22 +00:00
'';
in stdenv.mkDerivation rec {
inherit name version;
buildCommand = ''
mkdir -p $out/{bin,share/bash-completion/completions}
2017-08-16 00:39:22 +00:00
ln -s ${bin} $out/bin/wp
install -Dm644 ${completion} $out/share/bash-completion/completions/wp
2016-05-22 08:51:48 +00:00
'';
2016-09-13 10:20:51 +00:00
meta = with stdenv.lib; {
2016-05-22 08:51:48 +00:00
description = "A command line interface for WordPress";
2017-08-16 00:39:22 +00:00
homepage = https://wp-cli.org;
license = licenses.mit;
2016-09-13 10:20:51 +00:00
maintainers = with maintainers; [ peterhoeg ];
2017-08-16 00:39:22 +00:00
platforms = platforms.all;
2016-05-22 08:51:48 +00:00
};
}