nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv, lib, fetchurl, writeText, php, makeWrapper }:
2
3let
4 version = "2.2.0";
5
6 completion = fetchurl {
7 url = "https://raw.githubusercontent.com/wp-cli/wp-cli/v${version}/utils/wp-completion.bash";
8 sha256 = "15d330x6d3fizrm6ckzmdknqg6wjlx5fr87bmkbd5s6a1ihs0g24";
9 };
10
11 ini = writeText "php.ini" ''
12 [PHP]
13 memory_limit = -1 ; no limit as composer uses a lot of memory
14
15 [Phar]
16 phar.readonly = Off
17 '';
18
19in stdenv.mkDerivation rec {
20 pname = "wp-cli";
21 inherit version;
22
23 src = fetchurl {
24 url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${pname}-${version}.phar";
25 sha256 = "0s03jbsjwvkcbyss6rvpgw867hiwvk5p4n1qznkghyzi94j8mvki";
26 };
27
28 nativeBuildInputs = [ makeWrapper ];
29
30 buildCommand = ''
31 dir=$out/share/wp-cli
32 mkdir -p $out/bin $dir
33
34 install -Dm444 ${src} $dir/wp-cli
35 install -Dm444 ${ini} $dir/php.ini
36 install -Dm444 ${completion} $out/share/bash-completion/completions/wp
37
38 makeWrapper ${lib.getBin php}/bin/php $out/bin/wp \
39 --add-flags "-c $dir/php.ini" \
40 --add-flags "-f $dir/wp-cli"
41
42 # this is a very basic run test
43 $out/bin/wp --info >/dev/null
44 '';
45
46 meta = with 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}