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