wp-cli: add bash completion
Instead of creating 4 different tiny derivations, just stick everything into 1.
This commit is contained in:
parent
f673243aff
commit
025c571f1e
@ -1,33 +1,44 @@
|
||||
{ stdenv, lib, writeText, writeScript, fetchurl, php }:
|
||||
{ stdenv, lib, fetchurl, php }:
|
||||
|
||||
let
|
||||
version = "1.0.0";
|
||||
name = "wp-cli-${version}";
|
||||
|
||||
phpIni = writeText "wp-cli-php.ini" ''
|
||||
[Phar]
|
||||
phar.readonly = Off
|
||||
'';
|
||||
bin = "bin/wp";
|
||||
ini = "etc/php/wp-cli.ini";
|
||||
phar = "share/wp-cli/wp-cli.phar";
|
||||
|
||||
wpBin = writeScript "wp" ''
|
||||
#! ${stdenv.shell} -e
|
||||
exec ${php}/bin/php \
|
||||
-c ${phpIni} \
|
||||
-f ${src} "$@"
|
||||
'';
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${name}.phar";
|
||||
sha256 = "06a80fz9na9arjdpmnislwr0121kkg11kxfqmac0axa9vkv9fjcp";
|
||||
completion = fetchurl {
|
||||
url = "https://raw.githubusercontent.com/wp-cli/wp-cli/v${version}/utils/wp-completion.bash";
|
||||
sha256 = "15d330x6d3fizrm6ckzmdknqg6wjlx5fr87bmkbd5s6a1ihs0g24";
|
||||
};
|
||||
|
||||
in stdenv.mkDerivation rec {
|
||||
name = "wp-cli-${version}";
|
||||
|
||||
inherit name src;
|
||||
src = fetchurl {
|
||||
url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/${name}.phar";
|
||||
sha256 = "06a80fz9na9arjdpmnislwr0121kkg11kxfqmac0axa9vkv9fjcp";
|
||||
};
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p $out/bin
|
||||
ln -s ${wpBin} $out/bin/wp
|
||||
mkdir -p $out/bin $out/etc/php
|
||||
|
||||
cat <<_EOF > $out/${bin}
|
||||
#! ${stdenv.shell} -eu
|
||||
exec ${lib.getBin php}/bin/php \\
|
||||
-c $out/${ini} \\
|
||||
-f $out/${phar} "\$@"
|
||||
_EOF
|
||||
chmod 755 $out/${bin}
|
||||
|
||||
cat <<_EOF > $out/${ini}
|
||||
[Phar]
|
||||
phar.readonly = Off
|
||||
_EOF
|
||||
chmod 644 $out/${ini}
|
||||
|
||||
install -Dm644 ${src} $out/${phar}
|
||||
install -Dm644 ${completion} $out/share/bash-completion/completions/wp
|
||||
'';
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
|
Loading…
Reference in New Issue
Block a user