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