about summary refs log tree commit diff
path: root/pkgs/tools/misc/vdirsyncer/default.nix
blob: 9e9ded5c3a7601ae565a08f8eab2ba947c65cb76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ stdenv, python3Packages, glibcLocales, rustPlatform }:

# Packaging documentation at:
# https://github.com/untitaker/vdirsyncer/blob/master/docs/packaging.rst
let
  pythonPackages = python3Packages;
  version = "0.17.0a2";
  pname = "vdirsyncer";
  name = pname + "-" + version;
  src = pythonPackages.fetchPypi {
    inherit pname version;
    sha256 = "0y464rsx5la6bp94z2g0nnkbl4nwfya08abynvifw4c84vs1gr4q";
  };
  native = rustPlatform.buildRustPackage {
    name = name + "-native";
    inherit src;
    sourceRoot = name + "/rust";
    cargoSha256 = "1cr7xs11gbsc3x5slga9qahchwc22qq49amf28g4jgs9lzf57qis";
    postInstall = ''
      mkdir $out/include $out/lib
      cp $out/bin/libvdirsyncer_rustext* $out/lib
      rm -r $out/bin
      cp target/vdirsyncer_rustext.h $out/include
    '';
  };
in pythonPackages.buildPythonApplication rec {
  inherit version pname src;

  propagatedBuildInputs = with pythonPackages; [
    click click-log click-threading
    requests_toolbelt
    requests
    requests_oauthlib # required for google oauth sync
    atomicwrites
    milksnake
  ];

  buildInputs = with pythonPackages; [ setuptools_scm ];

  checkInputs = with pythonPackages; [ hypothesis pytest pytest-localserver pytest-subtesthack ] ++ [ glibcLocales ];

  postPatch = ''
    sed -i "/cargo build/d" Makefile
  '';

  preBuild = ''
    mkdir -p rust/target/release
    ln -s ${native}/lib/libvdirsyncer_rustext* rust/target/release/
    ln -s ${native}/include/vdirsyncer_rustext.h rust/target/
  '';

  LC_ALL = "en_US.utf8";

  preCheck = ''
    ln -sf ../dist/tmpbuild/vdirsyncer/vdirsyncer/_native__lib.so vdirsyncer
  '';

  checkPhase = ''
    runHook preCheck
    make DETERMINISTIC_TESTS=true test
    runHook postCheck
  '';

  meta = with stdenv.lib; {
    homepage = https://github.com/pimutils/vdirsyncer;
    description = "Synchronize calendars and contacts";
    maintainers = with maintainers; [ jgeerds ];
    platforms = platforms.all;
    license = licenses.mit;
  };
}