1{ lib
2, stdenv
3, acl
4, e2fsprogs
5, libb2
6, lz4
7, openssh
8, openssl
9, python3
10, zstd
11, nixosTests
12}:
13
14python3.pkgs.buildPythonApplication rec {
15 pname = "borgbackup";
16 version = "1.1.17";
17
18 src = python3.pkgs.fetchPypi {
19 inherit pname version;
20 sha256 = "0x0ncy0b0bmf586hbdgrif3gjmkdw760vfnfxndr493v07y29fbs";
21 };
22
23 postPatch = ''
24 # sandbox does not support setuid/setgid/sticky bits
25 substituteInPlace src/borg/testsuite/archiver.py \
26 --replace "0o4755" "0o0755"
27 '';
28
29 nativeBuildInputs = with python3.pkgs; [
30 setuptools-scm
31 # For building documentation:
32 sphinx
33 guzzle_sphinx_theme
34 ];
35
36 buildInputs = [
37 libb2
38 lz4
39 zstd
40 openssl
41 ] ++ lib.optionals stdenv.isLinux [
42 acl
43 ];
44
45 propagatedBuildInputs = with python3.pkgs; [
46 cython
47 llfuse
48 packaging
49 ] ++ lib.optionals (!stdenv.isDarwin) [
50 pyfuse3
51 ];
52
53 preConfigure = ''
54 export BORG_OPENSSL_PREFIX="${openssl.dev}"
55 export BORG_LZ4_PREFIX="${lz4.dev}"
56 export BORG_LIBB2_PREFIX="${libb2}"
57 export BORG_LIBZSTD_PREFIX="${zstd.dev}"
58 '';
59
60 makeWrapperArgs = [
61 ''--prefix PATH ':' "${openssh}/bin"''
62 ];
63
64 postInstall = ''
65 make -C docs singlehtml
66 mkdir -p $out/share/doc/borg
67 cp -R docs/_build/singlehtml $out/share/doc/borg/html
68
69 make -C docs man
70 mkdir -p $out/share/man
71 cp -R docs/_build/man $out/share/man/man1
72
73 mkdir -p $out/share/bash-completion/completions
74 cp scripts/shell_completions/bash/borg $out/share/bash-completion/completions/
75
76 mkdir -p $out/share/fish/vendor_completions.d
77 cp scripts/shell_completions/fish/borg.fish $out/share/fish/vendor_completions.d/
78
79 mkdir -p $out/share/zsh/site-functions
80 cp scripts/shell_completions/zsh/_borg $out/share/zsh/site-functions/
81 '';
82
83 checkInputs = with python3.pkgs; [
84 e2fsprogs
85 pytest-benchmark
86 pytest-xdist
87 pytestCheckHook
88 ];
89
90 pytestFlagsArray = [
91 "--numprocesses" "auto"
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_readonly_mount"
104 # Error: Permission denied while trying to write to /var/{,tmp}
105 "test_get_cache_dir"
106 "test_get_keys_dir"
107 "test_get_security_dir"
108 "test_get_config_dir"
109 ];
110
111 preCheck = ''
112 export HOME=$TEMP
113 '';
114
115 passthru.tests = {
116 inherit (nixosTests) borgbackup;
117 };
118
119 outputs = [ "out" "doc" ];
120
121 meta = with lib; {
122 description = "Deduplicating archiver with compression and encryption";
123 homepage = "https://www.borgbackup.org";
124 license = licenses.bsd3;
125 platforms = platforms.unix; # Darwin and FreeBSD mentioned on homepage
126 maintainers = with maintainers; [ flokli dotlambda globin ];
127 };
128}