@@ -1,18 +1,30 @@
1−{ stdenv, fetchurl, python3Packages, glibcLocales }:
1+{ stdenv, python3Packages, glibcLocales, rustPlatform }:
22
33# Packaging documentation at:
44# https://github.com/untitaker/vdirsyncer/blob/master/docs/packaging.rst
55let
66 pythonPackages = python3Packages;
7−in
8−pythonPackages.buildPythonApplication rec {
9− version = "0.16.4";
10− name = "vdirsyncer-${version}";
11−
12− src = fetchurl {
13− url = "mirror://pypi/v/vdirsyncer/${name}.tar.gz";
14− sha256 = "03wva48bgv1ad3df6plc9b8xxh6k8bcaxrhlzwh81c9mzn5bspzv";
7+ version = "0.17.0a2";
8+ pname = "vdirsyncer";
9+ name = pname + "-" + version;
10+ src = pythonPackages.fetchPypi {
11+ inherit pname version;
12+ sha256 = "0y464rsx5la6bp94z2g0nnkbl4nwfya08abynvifw4c84vs1gr4q";
1513 };
14+ native = rustPlatform.buildRustPackage {
15+ name = name + "-native";
16+ inherit src;
17+ sourceRoot = name + "/rust";
18+ cargoSha256 = "1cr7xs11gbsc3x5slga9qahchwc22qq49amf28g4jgs9lzf57qis";
19+ postInstall = ''
20+ mkdir $out/include $out/lib
21+ cp $out/bin/libvdirsyncer_rustext* $out/lib
22+ rm -r $out/bin
23+ cp target/vdirsyncer_rustext.h $out/include
24+ '';
25+ };
26+in pythonPackages.buildPythonApplication rec {
27+ inherit version pname src;
1628
1729 propagatedBuildInputs = with pythonPackages; [
1830 click click-log click-threading
@@ -20,14 +32,33 @@ pythonPackages.buildPythonApplication rec {
2032 requests
2133 requests_oauthlib # required for google oauth sync
2234 atomicwrites
35+ milksnake
2336 ];
2437
25− buildInputs = with pythonPackages; [hypothesis pytest pytest-localserver pytest-subtesthack setuptools_scm ] ++ [ glibcLocales ];
38+ buildInputs = with pythonPackages; [ setuptools_scm ];
39+
40+ checkInputs = with pythonPackages; [ hypothesis pytest pytest-localserver pytest-subtesthack ] ++ [ glibcLocales ];
41+
42+ postPatch = ''
43+ sed -i "/cargo build/d" Makefile
44+ '';
45+
46+ preBuild = ''
47+ mkdir -p rust/target/release
48+ ln -s ${native}/lib/libvdirsyncer_rustext* rust/target/release/
49+ ln -s ${native}/include/vdirsyncer_rustext.h rust/target/
50+ '';
2651
2752 LC_ALL = "en_US.utf8";
2853
54+ preCheck = ''
55+ ln -sf ../dist/tmpbuild/vdirsyncer/vdirsyncer/_native__lib.so vdirsyncer
56+ '';
57+
2958 checkPhase = ''
59+ runHook preCheck
3060 make DETERMINISTIC_TESTS=true test
61+ runHook postCheck
3162 '';
3263
3364 meta = with stdenv.lib; {