nixpkgs/pkgs/tools/backup/duplicity/default.nix

147 lines
3.7 KiB
Nix
Raw Normal View History

{ lib, stdenv
2021-07-11 12:00:00 +00:00
, fetchFromGitLab
, fetchpatch
2021-07-21 10:52:00 +00:00
, python3
, librsync
, ncftp
, gnupg
, gnutar
, par2cmdline
2020-11-24 15:29:28 +00:00
, util-linux
, rsync
, makeWrapper
2020-03-11 11:43:50 +00:00
, gettext
}:
2020-03-11 11:43:50 +00:00
let
2021-07-21 10:52:00 +00:00
pythonPackages = python3.pkgs;
2021-01-15 09:19:50 +00:00
inherit (lib.versions) majorMinor splitVersion;
majorMinorPatch = v: builtins.concatStringsSep "." (lib.take 3 (splitVersion v));
2020-03-11 11:43:50 +00:00
in
pythonPackages.buildPythonApplication rec {
2019-08-31 11:41:23 +00:00
pname = "duplicity";
2021-07-11 12:00:00 +00:00
version = "0.8.20";
2021-07-11 12:00:00 +00:00
src = fetchFromGitLab {
owner = "duplicity";
repo = "duplicity";
rev = "rel.${version}";
sha256 = "13ghra0myq6h6yx8qli55bh8dg91nf1hpd8l7d7xamgrw6b188sm";
};
patches = [
# We use the tar binary on all platforms.
./gnutar-in-test.patch
# Our Python infrastructure runs test in installCheckPhase so we need
# to make the testing code stop assuming it is run from the source directory.
./use-installed-scripts-in-test.patch
2021-07-11 12:00:00 +00:00
# https://gitlab.com/duplicity/duplicity/-/merge_requests/64
# remove on next release
(fetchpatch {
url = "https://gitlab.com/duplicity/duplicity/-/commit/5c229a9b42f67257c747fbc0022c698fec405bbc.patch";
sha256 = "05v931rnawfv11cyxj8gykmal8rj5vq2ksdysyr2mb4sl81mi7v0";
})
2021-01-15 09:19:50 +00:00
] ++ lib.optionals stdenv.isLinux [
# Broken on Linux in Nix' build environment
./linux-disable-timezone-test.patch
];
SETUPTOOLS_SCM_PRETEND_VERSION = version;
2021-07-11 12:00:00 +00:00
preConfigure = ''
# fix version displayed by duplicity --version
# see SourceCopy in setup.py
ls
for i in bin/*.1 duplicity/__init__.py; do
substituteInPlace "$i" --replace '$version' "${version}"
done
'';
2020-03-11 11:43:50 +00:00
nativeBuildInputs = [
makeWrapper
2020-03-11 11:43:50 +00:00
gettext
pythonPackages.wrapPython
pythonPackages.setuptools-scm
];
2020-03-11 11:43:50 +00:00
buildInputs = [
librsync
];
2021-04-04 12:49:39 +00:00
pythonPath = with pythonPackages; [
b2sdk
boto
boto3
cffi
cryptography
ecdsa
idna
pygobject3
fasteners
ipaddress
lockfile
paramiko
pyasn1
pycrypto
pydrive2
future
2021-01-15 09:19:50 +00:00
] ++ lib.optionals (!isPy3k) [
enum
];
checkInputs = [
gnupg # Add 'gpg' to PATH.
gnutar # Add 'tar' to PATH.
librsync # Add 'rdiff' to PATH.
par2cmdline # Add 'par2' to PATH.
2021-01-15 09:19:50 +00:00
] ++ lib.optionals stdenv.isLinux [
2020-11-24 15:29:28 +00:00
util-linux # Add 'setsid' to PATH.
] ++ (with pythonPackages; [
lockfile
mock
pexpect
pytest
pytest-runner
]);
2017-03-24 09:48:00 +00:00
2016-10-27 15:15:18 +00:00
postInstall = ''
wrapProgram $out/bin/duplicity \
2021-01-15 09:19:50 +00:00
--prefix PATH : "${lib.makeBinPath [ gnupg ncftp rsync ]}"
2017-03-24 09:48:00 +00:00
'';
2016-10-27 15:15:18 +00:00
2017-03-24 09:48:00 +00:00
preCheck = ''
wrapPythonProgramsIn "$PWD/testing/overrides/bin" "$pythonPath"
2016-10-27 15:15:18 +00:00
# Add 'duplicity' to PATH for tests.
# Normally, 'setup.py test' adds 'build/scripts-2.7/' to PATH before running
# tests. However, 'build/scripts-2.7/duplicity' is not wrapped, so its
# shebang is incorrect and it fails to run inside Nix' sandbox.
# In combination with use-installed-scripts-in-test.patch, make 'setup.py
# test' use the installed 'duplicity' instead.
PATH="$out/bin:$PATH"
# Don't run developer-only checks (pep8, etc.).
export RUN_CODE_TESTS=0
2021-07-11 12:00:00 +00:00
# check version string
duplicity --version | grep ${version}
2021-01-15 09:19:50 +00:00
'' + lib.optionalString stdenv.isDarwin ''
# Work around the following error when running tests:
# > Max open files of 256 is too low, should be >= 1024.
# > Use 'ulimit -n 1024' or higher to correct.
ulimit -n 1024
2017-03-24 09:48:00 +00:00
'';
# TODO: Fix test failures on macOS 10.13:
#
# > OSError: out of pty devices
doCheck = !stdenv.isDarwin;
meta = with lib; {
description = "Encrypted bandwidth-efficient backup using the rsync algorithm";
homepage = "https://duplicity.gitlab.io/duplicity-web/";
2017-03-24 09:48:00 +00:00
license = licenses.gpl2Plus;
platforms = platforms.unix;
};
}