1{ lib
2, stdenv
3, acl
4, e2fsprogs
5, libb2
6, lz4
7, openssh
8, openssl
9, python3Packages
10, xxHash
11, zstd
12, installShellFiles
13, nixosTests
14, fetchPypi
15}:
16
17python3Packages.buildPythonApplication rec {
18 pname = "borgbackup";
19 version = "1.2.6";
20 format = "pyproject";
21
22 src = fetchPypi {
23 inherit pname version;
24 hash = "sha256-t6b48IYDnu7HkHC5FPPGUe1/NhLJZTdK+RDSd8eiE50=";
25 };
26
27 postPatch = ''
28 # sandbox does not support setuid/setgid/sticky bits
29 substituteInPlace src/borg/testsuite/archiver.py \
30 --replace "0o4755" "0o0755"
31 '';
32
33 nativeBuildInputs = with python3Packages; [
34 cython
35 setuptools-scm
36 pkgconfig
37
38 # docs
39 sphinxHook
40 guzzle-sphinx-theme
41
42 # shell completions
43 installShellFiles
44 ];
45
46 sphinxBuilders = [ "singlehtml" "man" ];
47
48 buildInputs = [
49 libb2
50 lz4
51 xxHash
52 zstd
53 openssl
54 ] ++ lib.optionals stdenv.isLinux [
55 acl
56 ];
57
58 propagatedBuildInputs = with python3Packages; [
59 msgpack
60 packaging
61 (if stdenv.isLinux then pyfuse3 else llfuse)
62 ];
63
64 makeWrapperArgs = [
65 ''--prefix PATH ':' "${openssh}/bin"''
66 ];
67
68 postInstall = ''
69 installShellCompletion --cmd borg \
70 --bash scripts/shell_completions/bash/borg \
71 --fish scripts/shell_completions/fish/borg.fish \
72 --zsh scripts/shell_completions/zsh/_borg
73 '';
74
75 nativeCheckInputs = with python3Packages; [
76 e2fsprogs
77 py
78 python-dateutil
79 pytest-benchmark
80 pytest-xdist
81 pytestCheckHook
82 ];
83
84 pytestFlagsArray = [
85 "--benchmark-skip"
86 "--pyargs" "borg.testsuite"
87 ];
88
89 disabledTests = [
90 # fuse: device not found, try 'modprobe fuse' first
91 "test_fuse"
92 "test_fuse_allow_damaged_files"
93 "test_fuse_mount_hardlinks"
94 "test_fuse_mount_options"
95 "test_fuse_versions_view"
96 "test_migrate_lock_alive"
97 "test_readonly_mount"
98 # Error: Permission denied while trying to write to /var/{,tmp}
99 "test_get_cache_dir"
100 "test_get_keys_dir"
101 "test_get_security_dir"
102 "test_get_config_dir"
103 # https://github.com/borgbackup/borg/issues/6573
104 "test_basic_functionality"
105 ];
106
107 preCheck = ''
108 export HOME=$TEMP
109 '';
110
111 passthru.tests = {
112 inherit (nixosTests) borgbackup;
113 };
114
115 outputs = [ "out" "doc" "man" ];
116
117 meta = with lib; {
118 changelog = "https://github.com/borgbackup/borg/blob/${version}/docs/changes.rst";
119 description = "Deduplicating archiver with compression and encryption";
120 homepage = "https://www.borgbackup.org";
121 license = licenses.bsd3;
122 platforms = platforms.unix; # Darwin and FreeBSD mentioned on homepage
123 mainProgram = "borg";
124 maintainers = with maintainers; [ dotlambda globin ];
125 };
126}