nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv, fetchpatch, fetchurl, python2Packages, librsync, ncftp, gnupg
2, gnutar
3, par2cmdline
4, utillinux
5, rsync
6, backblaze-b2, makeWrapper }:
7
8python2Packages.buildPythonApplication rec {
9 pname = "duplicity";
10 version = "0.7.19";
11
12 src = fetchurl {
13 url = "https://code.launchpad.net/duplicity/${stdenv.lib.versions.majorMinor version}-series/${version}/+download/${pname}-${version}.tar.gz";
14 sha256 = "0ag9dknslxlasslwfjhqgcqbkb1mvzzx93ry7lch2lfzcdd91am6";
15 };
16 patches = [
17 ./gnutar-in-test.patch
18 ./use-installed-scripts-in-test.patch
19
20 # The following patches improve the performance of installCheckPhase:
21 # Ensure all duplicity output is captured in tests
22 (fetchpatch {
23 extraPrefix = "";
24 sha256 = "07ay3mmnw8p2j3v8yvcpjsx0rf2jqly9ablwjpmry23dz9f0mxsd";
25 url = "https://bazaar.launchpad.net/~duplicity-team/duplicity/0.8-series/diff/1359.2.1";
26 })
27 # Minimize time spent sleeping between backups
28 (fetchpatch {
29 extraPrefix = "";
30 sha256 = "0v99q6mvikb8sf68gh3s0zg12pq8fijs87fv1qrvdnc8zvs4pmfs";
31 url = "https://bazaar.launchpad.net/~duplicity-team/duplicity/0.8-series/diff/1359.2.2";
32 })
33 # Remove unnecessary sleeping after running backups in tests
34 (fetchpatch {
35 extraPrefix = "";
36 sha256 = "1bmgp4ilq2gwz2k73fxrqplf866hj57lbyabaqpkvwxhr0ch1jiq";
37 url = "https://bazaar.launchpad.net/~duplicity-team/duplicity/0.8-series/diff/1359.2.3";
38 })
39 ] ++ stdenv.lib.optionals stdenv.isLinux [
40 ./linux-disable-timezone-test.patch
41 ];
42
43 buildInputs = [ librsync makeWrapper python2Packages.wrapPython ];
44 propagatedBuildInputs = [ backblaze-b2 ] ++ (with python2Packages; [
45 boto cffi cryptography ecdsa enum idna pygobject3 fasteners
46 ipaddress lockfile paramiko pyasn1 pycrypto six pydrive
47 ]);
48 checkInputs = [
49 gnupg # Add 'gpg' to PATH.
50 gnutar # Add 'tar' to PATH.
51 librsync # Add 'rdiff' to PATH.
52 par2cmdline # Add 'par2' to PATH.
53 ] ++ stdenv.lib.optionals stdenv.isLinux [
54 utillinux # Add 'setsid' to PATH.
55 ] ++ (with python2Packages; [ lockfile mock pexpect ]);
56
57 postInstall = ''
58 wrapProgram $out/bin/duplicity \
59 --prefix PATH : "${stdenv.lib.makeBinPath [ gnupg ncftp rsync ]}"
60
61 wrapPythonPrograms
62 '';
63
64 preCheck = ''
65 wrapPythonProgramsIn "$PWD/testing/overrides/bin" "$pythonPath"
66
67 # Add 'duplicity' to PATH for tests.
68 # Normally, 'setup.py test' adds 'build/scripts-2.7/' to PATH before running
69 # tests. However, 'build/scripts-2.7/duplicity' is not wrapped, so its
70 # shebang is incorrect and it fails to run inside Nix' sandbox.
71 # In combination with use-installed-scripts-in-test.patch, make 'setup.py
72 # test' use the installed 'duplicity' instead.
73 PATH="$out/bin:$PATH"
74
75 # Don't run developer-only checks (pep8, etc.).
76 export RUN_CODE_TESTS=0
77 '' + stdenv.lib.optionalString stdenv.isDarwin ''
78 # Work around the following error when running tests:
79 # > Max open files of 256 is too low, should be >= 1024.
80 # > Use 'ulimit -n 1024' or higher to correct.
81 ulimit -n 1024
82 '';
83
84 # TODO: Fix test failures on macOS 10.13:
85 #
86 # > OSError: out of pty devices
87 doCheck = !stdenv.isDarwin;
88
89 meta = with stdenv.lib; {
90 description = "Encrypted bandwidth-efficient backup using the rsync algorithm";
91 homepage = https://www.nongnu.org/duplicity;
92 license = licenses.gpl2Plus;
93 maintainers = with maintainers; [ peti ];
94 platforms = platforms.unix;
95 };
96}