1{ stdenv
2, buildPythonPackage
3, fetchFromGitHub
4, isPy27
5, fetchpatch
6, rustPlatform
7, pkg-config
8, openssl
9, CoreServices
10, Security
11, click
12, click-log
13, click-threading
14, requests_toolbelt
15, requests
16, requests_oauthlib # required for google oauth sync
17, atomicwrites
18, milksnake
19, shippai
20, hypothesis
21, pytest
22, pytest-localserver
23, pytest-subtesthack
24, setuptools_scm
25}:
26
27# Packaging documentation at:
28# https://github.com/untitaker/vdirsyncer/blob/master/docs/packaging.rst
29buildPythonPackage rec {
30 version = "unstable-2018-08-05";
31 pname = "vdirsyncer";
32 name = "${pname}-${version}";
33 disabled = isPy27;
34
35 src = fetchFromGitHub {
36 owner = "spk";
37 repo = pname;
38 # fix-build-style branch, see https://github.com/pimutils/vdirsyncer/pull/798
39 rev = "2c62d03bd73f8b44a47c2e769ade046697896ae9";
40 sha256 = "1q6xvzz5rf5sqdaj3mdvhpgwy5b16isavgg7vardgjwqwv1yal28";
41 };
42
43 native = rustPlatform.buildRustPackage {
44 name = "${name}-native";
45 inherit src;
46 sourceRoot = "source/rust";
47 cargoSha256 = "0cqy0s55pkg6hww86h7qip4xaidh6g8lcypdj84n2x374jq38c5d";
48 nativeBuildInputs = [ pkg-config ];
49 buildInputs = [ openssl ] ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices Security ];
50 };
51
52 propagatedBuildInputs = [
53 click click-log click-threading
54 requests_toolbelt
55 requests
56 requests_oauthlib # required for google oauth sync
57 atomicwrites
58 milksnake
59 shippai
60 ];
61
62 nativeBuildInputs = [
63 setuptools_scm
64 ];
65
66 checkInputs = [
67 hypothesis
68 pytest
69 pytest-localserver
70 pytest-subtesthack
71 ];
72
73 patches = [
74 (fetchpatch {
75 url = "https://github.com/pimutils/vdirsyncer/commit/7b636e8e40d69c495901f965b9c0686513659e44.patch";
76 sha256 = "0vl942ii5iad47y63v0ngmhfp37n30nxyk4j7h64b95fk38vfwx9";
77 })
78 ];
79
80 postPatch = ''
81 # see https://github.com/pimutils/vdirsyncer/pull/805
82 substituteInPlace setup.cfg --replace --duration --durations
83
84 # for setuptools_scm:
85 echo 'Version: ${version}' >PKG-INFO
86
87 sed -i 's/spec.add_external_build(cmd=cmd/spec.add_external_build(cmd="true"/g' setup.py
88
89 # fixing test
90 sed -i "s/invalid value for \"--verbosity\"/invalid value for \\\'--verbosity\\\'/" tests/system/cli/test_sync.py
91 '';
92
93 preBuild = ''
94 mkdir -p rust/target/release
95 ln -s ${native}/lib/libvdirsyncer_rustext* rust/target/release/
96 '';
97
98 checkPhase = ''
99 rm -rf vdirsyncer
100 make DETERMINISTIC_TESTS=true PYTEST_ARGS="--deselect=tests/unit/utils/test_vobject.py::test_replace_uid --deselect=tests/unit/sync/test_sync.py::TestSyncMachine" test
101 '';
102
103 meta = with stdenv.lib; {
104 homepage = "https://github.com/pimutils/vdirsyncer";
105 description = "Synchronize calendars and contacts";
106 maintainers = with maintainers; [ matthiasbeyer gebner ];
107 license = licenses.mit;
108 };
109}