nixpkgs/pkgs/development/tools/backblaze-b2/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

104 lines
2.6 KiB
Nix
Raw Normal View History

2024-03-28 01:21:08 +03:00
{ lib
, python3Packages
, fetchFromGitHub
, installShellFiles
, testers
, backblaze-b2
# executable is renamed to backblaze-b2 by default, to avoid collision with boost's 'b2'
, execName ? "backblaze-b2"
}:
2016-02-04 02:45:01 +03:00
2020-09-25 23:29:52 +03:00
python3Packages.buildPythonApplication rec {
2017-12-02 16:42:13 +03:00
pname = "backblaze-b2";
version = "3.18.0";
pyproject = true;
2016-02-04 02:45:01 +03:00
2024-03-28 01:21:08 +03:00
src = fetchFromGitHub {
owner = "Backblaze";
repo = "B2_Command_Line_Tool";
rev = "refs/tags/v${version}";
hash = "sha256-1UXByc3jjp8GN7+aI2GBohJ0DFxgp604QOsXp5GaL4Q=";
2016-02-04 02:45:01 +03:00
};
nativeBuildInputs = [
installShellFiles
];
build-system = with python3Packages; [
2024-03-28 01:21:08 +03:00
pdm-backend
];
dependencies = with python3Packages; [
argcomplete
arrow
2020-09-25 23:29:52 +03:00
b2sdk
2020-11-25 00:36:26 +03:00
phx-class-registry
docutils
rst2ansi
2022-08-14 19:47:13 +03:00
tabulate
tqdm
2023-12-14 12:28:00 +03:00
platformdirs
packaging
setuptools
];
nativeCheckInputs = with python3Packages; [
2022-08-14 19:47:13 +03:00
backoff
2022-09-20 09:19:04 +03:00
more-itertools
pexpect
2024-03-28 01:21:08 +03:00
pytestCheckHook
pytest-xdist
2021-10-24 22:20:04 +03:00
];
2016-02-04 02:45:01 +03:00
2022-08-14 19:47:13 +03:00
preCheck = ''
export HOME=$(mktemp -d)
'';
disabledTestPaths = [
# Test requires network
2022-08-14 19:47:13 +03:00
"test/integration/test_b2_command_line.py"
2024-03-28 01:21:08 +03:00
"test/integration/test_tqdm_closer.py"
# it's hard to make it work on nix
"test/integration/test_autocomplete.py"
2024-03-28 01:21:08 +03:00
"test/unit/test_console_tool.py"
# this one causes successive tests to fail
"test/unit/_cli/test_autocomplete_cache.py"
2020-11-25 00:36:26 +03:00
];
disabledTests = [
# Autocomplete is not successful in a sandbox
"test_autocomplete_installer"
"test_help"
"test_install_autocomplete"
];
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})
2016-02-04 02:45:01 +03:00
'';
2023-12-22 11:13:56 +03:00
passthru.tests.version = (testers.testVersion {
package = backblaze-b2;
command = "${execName} version --short";
2023-12-22 11:13:56 +03:00
}).overrideAttrs (old: {
# workaround the error: Permission denied: '/homeless-shelter'
# backblaze-b2 fails to create a 'b2' directory under the XDG config path
2024-03-28 01:21:08 +03:00
preHook = ''
export HOME=$(mktemp -d)
'';
2023-12-22 11:13:56 +03:00
});
2017-12-02 16:42:13 +03:00
meta = with lib; {
description = "Command-line tool for accessing the Backblaze B2 storage service";
homepage = "https://github.com/Backblaze/B2_Command_Line_Tool";
2023-09-04 18:02:27 +03:00
changelog = "https://github.com/Backblaze/B2_Command_Line_Tool/blob/v${version}/CHANGELOG.md";
2016-03-06 20:14:25 +03:00
license = licenses.mit;
maintainers = with maintainers; [ hrdinka tomhoule ];
mainProgram = "backblaze-b2";
2016-02-04 02:45:01 +03:00
};
}