3
0
Fork 0
forked from mirrors/nixpkgs

wp-cli: allow overriding entire config file

This commit is contained in:
Peter Hoeg 2023-11-15 22:04:36 +01:00
parent c4b7e013aa
commit 437ced8331
3 changed files with 80 additions and 61 deletions

View file

@ -0,0 +1,80 @@
{ stdenv
, lib
, fetchurl
, formats
, installShellFiles
, makeWrapper
, php
, phpIniFile ? null
}:
let
version = "2.9.0";
completion = fetchurl {
url = "https://raw.githubusercontent.com/wp-cli/wp-cli/v${version}/utils/wp-completion.bash";
hash = "sha256-RDygYQzK6NLWrOug7EqnkpuH7Wz1T2Zq/tGNZjoYo5U=";
};
ini =
if phpIniFile == null
then
(formats.ini { }).generate "php.ini"
{
PHP.memory_limit = -1; # no limit as composer uses a lot of memory
Phar."phar.readonly" = "Off";
}
else phpIniFile;
in
stdenv.mkDerivation (finalAttrs: {
pname = "wp-cli";
inherit version;
src = fetchurl {
url = "https://github.com/wp-cli/wp-cli/releases/download/v${version}/wp-cli-${version}.phar";
hash = "sha256-r2t8zCHtCQfLUE21oFnw4SAReQWmAXv91Ddc7jyT2GQ=";
};
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
nativeBuildInputs = [ installShellFiles makeWrapper ];
installPhase = ''
runHook preInstall
install -Dm444 ${finalAttrs.src} $out/share/wp-cli/wp-cli.phar
install -Dm444 ${ini} $out/etc/${ini.name}
installShellCompletion --bash --name wp ${completion}
makeWrapper ${lib.getExe php} $out/bin/${finalAttrs.meta.mainProgram} \
--set-default XDG_CACHE_HOME \$HOME/.cache \
--set-default XDG_CONFIG_HOME \$HOME/.config \
--set-default XDG_DATA_HOME \$HOME/.local/share \
--set-default WP_CLI_CONFIG_PATH \$XDG_CONFIG_HOME}/wp-cli \
--set-default WP_CLI_PACKAGES_DIR \$XDG_DATA_HOME/wp-cli \
--set-default WP_CLI_CACHE_DIR \$XDG_CACHE_HOME/wp-cli \
--add-flags "-c $out/etc/${ini.name}" \
--add-flags "-f $out/share/wp-cli/wp-cli.phar" \
--add-flags "--"
runHook postInstall
'';
doInstallCheck = true;
installCheckPhase = ''
$out/bin/wp --info
'';
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;
mainProgram = "wp";
};
})

View file

@ -1,59 +0,0 @@
{ stdenv
, lib
, fetchurl
, formats
, installShellFiles
, makeWrapper
, php
}:
let
version = "2.9.0";
completion = fetchurl {
url = "https://raw.githubusercontent.com/wp-cli/wp-cli/v${version}/utils/wp-completion.bash";
hash = "sha256-RDygYQzK6NLWrOug7EqnkpuH7Wz1T2Zq/tGNZjoYo5U=";
};
ini = (formats.ini { }).generate "php.ini" {
PHP.memory_limit = -1; # no limit as composer uses a lot of memory
Phar."phar.readonly" = "Off";
};
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";
hash = "sha256-r2t8zCHtCQfLUE21oFnw4SAReQWmAXv91Ddc7jyT2GQ=";
};
nativeBuildInputs = [ installShellFiles makeWrapper ];
buildCommand = ''
dir=$out/share/wp-cli
install -Dm444 ${src} $dir/wp-cli
install -Dm444 ${ini} $dir/php.ini
installShellCompletion --bash --name wp ${completion}
mkdir -p $out/bin
makeWrapper ${lib.getBin php}/bin/php $out/bin/wp \
--add-flags "-c $dir/php.ini" \
--add-flags "-f $dir/wp-cli" \
--add-flags "--"
# 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;
mainProgram = "wp";
};
}

View file

@ -36536,8 +36536,6 @@ with pkgs;
wp4nix = callPackage ../development/tools/wp4nix { };
wp-cli = callPackage ../development/tools/wp-cli { };
wsjtx = qt5.callPackage ../applications/radio/wsjtx { };
wxhexeditor = callPackage ../applications/editors/wxhexeditor {