Skip to content
Permalink
Browse files

wp-cli: use 1 store path instead of 4

  • Loading branch information
peterhoeg committed Aug 10, 2018
1 parent 47349c0 commit c85f1c90f48d21ce17c2643b1f39d7baa0ea5fee
Showing with 27 additions and 23 deletions.
  1. +27 −23 pkgs/development/tools/wp-cli/default.nix
@@ -1,42 +1,46 @@
{ stdenv, lib, fetchurl, writeScript, writeText, php }:

let
name = "wp-cli-${version}";
version = "2.0.0";

src = fetchurl {
url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${name}.phar";
sha256 = "1s8pv8vdjwiwknpwsxc59l1zxc2np7nrp6bjd0s8jwsrv5fgjzsp";
};

completion = fetchurl {
url = "https://raw.githubusercontent.com/wp-cli/wp-cli/v${version}/utils/wp-completion.bash";
sha256 = "15d330x6d3fizrm6ckzmdknqg6wjlx5fr87bmkbd5s6a1ihs0g24";
};

bin = writeScript "wp" ''
#! ${stdenv.shell}
in stdenv.mkDerivation rec {
name = "wp-cli-${version}";
inherit version;

set -euo pipefail
src = fetchurl {
url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${name}.phar";
sha256 = "1s8pv8vdjwiwknpwsxc59l1zxc2np7nrp6bjd0s8jwsrv5fgjzsp";
};

exec ${lib.getBin php}/bin/php \
-c ${ini} \
-f ${src} -- "$@"
'';
buildCommand = ''
dir=$out/share/wp-cli
mkdir -p $out/bin $dir
ini = writeText "wp-cli.ini" ''
[PHP]
memory_limit = -1 ; no limit as composer uses a lot of memory
cat <<_EOF > $out/bin/wp
#!${stdenv.shell}
[Phar]
phar.readonly = Off
'';
set -euo pipefail
in stdenv.mkDerivation rec {
inherit name version;
exec ${lib.getBin php}/bin/php \\
-c $dir/php.ini \\
-f $dir/wp-cli -- "\$@"
_EOF
chmod 0755 $out/bin/wp
buildCommand = ''
install -Dm755 ${bin} $out/bin/wp
cat <<_EOF > $dir/php.ini
[PHP]
memory_limit = -1 ; no limit as composer uses a lot of memory
[Phar]
phar.readonly = Off
_EOF
install -Dm644 ${src} $dir/wp-cli
install -Dm644 ${completion} $out/share/bash-completion/completions/wp
# this is a very basic run test

0 comments on commit c85f1c9

Please sign in to comment.
You can’t perform that action at this time.