From 0613638ecdda5ed65ec2b90ad4b34bdd1c16ba5c Mon Sep 17 00:00:00 2001 From: Matthieu Coudron <886074+teto@users.noreply.github.com> Date: Sun, 21 Jan 2024 00:24:07 +0100 Subject: [PATCH] backblaze2-b2: support alternative executable name according to official doc backblaze.com/docs/cloud-storage-command-line-tools mentions the executable is supposed to be called `b2`. Several distributions including nixpkgs renamed it to `backblaze-b2` but it is annoying if you dont use boost's b2. This commit makes it possible to override the executable name to something else. --- .../tools/backblaze-b2/default.nix | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkgs/development/tools/backblaze-b2/default.nix b/pkgs/development/tools/backblaze-b2/default.nix index e37fd54832c2..e82c32940891 100644 --- a/pkgs/development/tools/backblaze-b2/default.nix +++ b/pkgs/development/tools/backblaze-b2/default.nix @@ -1,4 +1,7 @@ -{ lib, python3Packages, fetchPypi, installShellFiles, testers, backblaze-b2 }: +{ lib, python3Packages, fetchPypi, installShellFiles, testers, backblaze-b2 +# executable is renamed to backblaze-b2 by default, to avoid collision with boost's 'b2' +, execName ? "backblaze-b2" +}: python3Packages.buildPythonApplication rec { pname = "backblaze-b2"; @@ -68,17 +71,18 @@ python3Packages.buildPythonApplication rec { "test/unit/console_tool" ]; - postInstall = '' - mv "$out/bin/b2" "$out/bin/backblaze-b2" - - installShellCompletion --cmd backblaze-b2 \ - --bash <(${python3Packages.argcomplete}/bin/register-python-argcomplete backblaze-b2) \ - --zsh <(${python3Packages.argcomplete}/bin/register-python-argcomplete backblaze-b2) + postInstall = lib.optionalString (execName != "b2") '' + mv "$out/bin/b2" "$out/bin/${execName}" + '' + + '' + installShellCompletion --cmd ${execName} \ + --bash <(${python3Packages.argcomplete}/bin/register-python-argcomplete ${execName}) \ + --zsh <(${python3Packages.argcomplete}/bin/register-python-argcomplete ${execName}) ''; passthru.tests.version = (testers.testVersion { package = backblaze-b2; - command = "backblaze-b2 version --short"; + command = "${execName} version --short"; }).overrideAttrs (old: { # workaround the error: Permission denied: '/homeless-shelter' # backblaze-b2 fails to create a 'b2' directory under the XDG config path