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