1{ lib
2, stdenv
3, fetchFromGitLab
4, python3
5, librsync
6, ncftp
7, gnupg
8, gnutar
9, par2cmdline
10, util-linux
11, rsync
12, makeWrapper
13, gettext
14}:
15
16python3.pkgs.buildPythonApplication rec {
17 pname = "duplicity";
18 version = "0.8.23";
19
20 src = fetchFromGitLab {
21 owner = "duplicity";
22 repo = "duplicity";
23 rev = "rel.${version}";
24 sha256 = "0my015zc8751smjgbsysmca7hvdm96cjw5zilqn3zq971nmmrksb";
25 };
26
27 patches = [
28 # We use the tar binary on all platforms.
29 ./gnutar-in-test.patch
30
31 # Our Python infrastructure runs test in installCheckPhase so we need
32 # to make the testing code stop assuming it is run from the source directory.
33 ./use-installed-scripts-in-test.patch
34 ] ++ lib.optionals stdenv.isLinux [
35 # Broken on Linux in Nix' build environment
36 ./linux-disable-timezone-test.patch
37 ];
38
39 SETUPTOOLS_SCM_PRETEND_VERSION = version;
40
41 preConfigure = ''
42 # fix version displayed by duplicity --version
43 # see SourceCopy in setup.py
44 ls
45 for i in bin/*.1 duplicity/__init__.py; do
46 substituteInPlace "$i" --replace '$version' "${version}"
47 done
48 '';
49
50 nativeBuildInputs = [
51 makeWrapper
52 gettext
53 python3.pkgs.wrapPython
54 python3.pkgs.setuptools-scm
55 ];
56
57 buildInputs = [
58 librsync
59 ];
60
61 pythonPath = with python3.pkgs; [
62 b2sdk
63 boto3
64 cffi
65 cryptography
66 ecdsa
67 idna
68 pygobject3
69 fasteners
70 lockfile
71 paramiko
72 pyasn1
73 pycrypto
74 pydrive2
75 future
76 ];
77
78 nativeCheckInputs = [
79 gnupg # Add 'gpg' to PATH.
80 gnutar # Add 'tar' to PATH.
81 librsync # Add 'rdiff' to PATH.
82 par2cmdline # Add 'par2' to PATH.
83 ] ++ lib.optionals stdenv.isLinux [
84 util-linux # Add 'setsid' to PATH.
85 ] ++ (with python3.pkgs; [
86 lockfile
87 mock
88 pexpect
89 pytest
90 pytest-runner
91 ]);
92
93 postInstall = ''
94 wrapProgram $out/bin/duplicity \
95 --prefix PATH : "${lib.makeBinPath [ gnupg ncftp rsync ]}"
96 '';
97
98 preCheck = ''
99 wrapPythonProgramsIn "$PWD/testing/overrides/bin" "$pythonPath"
100
101 # Add 'duplicity' to PATH for tests.
102 # Normally, 'setup.py test' adds 'build/scripts-2.7/' to PATH before running
103 # tests. However, 'build/scripts-2.7/duplicity' is not wrapped, so its
104 # shebang is incorrect and it fails to run inside Nix' sandbox.
105 # In combination with use-installed-scripts-in-test.patch, make 'setup.py
106 # test' use the installed 'duplicity' instead.
107 PATH="$out/bin:$PATH"
108
109 # Don't run developer-only checks (pep8, etc.).
110 export RUN_CODE_TESTS=0
111
112 # check version string
113 duplicity --version | grep ${version}
114 '' + lib.optionalString stdenv.isDarwin ''
115 # Work around the following error when running tests:
116 # > Max open files of 256 is too low, should be >= 1024.
117 # > Use 'ulimit -n 1024' or higher to correct.
118 ulimit -n 1024
119 '';
120
121 # TODO: Fix test failures on macOS 10.13:
122 #
123 # > OSError: out of pty devices
124 doCheck = !stdenv.isDarwin;
125
126 meta = with lib; {
127 description = "Encrypted bandwidth-efficient backup using the rsync algorithm";
128 homepage = "https://duplicity.gitlab.io/duplicity-web/";
129 license = licenses.gpl2Plus;
130 maintainers = with maintainers; [ ];
131 };
132}