summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ev/evolution-data-server/package.nix
blob: 65178d7ce4cc5c9b7674093c16ec7f2a9557efda (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
{
  stdenv,
  lib,
  buildPackages,
  fetchurl,
  pkg-config,
  gnome,
  _experimental-update-script-combinators,
  python3,
  gobject-introspection,
  gettext,
  libsoup_3,
  libxml2,
  libsecret,
  icu,
  sqlite,
  libcanberra-gtk3,
  p11-kit,
  db,
  nspr,
  nss,
  libical,
  gperf,
  wrapGAppsHook3,
  glib-networking,
  gsettings-desktop-schemas,
  vala,
  cmake,
  ninja,
  libkrb5,
  openldap,
  enableOAuth2 ? stdenv.hostPlatform.isLinux,
  webkitgtk_4_1,
  webkitgtk_6_0,
  json-glib,
  glib,
  gtk3,
  gtk4,
  withGtk3 ? true,
  withGtk4 ? false,
  libphonenumber,
  libuuid,
  gnome-online-accounts,
  libgweather,
  boost,
  protobuf,
  libiconv,
  makeHardcodeGsettingsPatch,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "evolution-data-server";
  version = "3.60.2";

  outputs = [
    "out"
    "dev"
  ];

  src = fetchurl {
    url = "mirror://gnome/sources/evolution-data-server/${lib.versions.majorMinor finalAttrs.version}/evolution-data-server-${finalAttrs.version}.tar.xz";
    hash = "sha256-IITb2sOWNxs2XVBMH/RYZrqNyi8SUuXaHT2cM6vcEoY=";
  };

  patches = [
    # Avoid using wrapper function, which the hardcode gsettings
    # patch generator cannot handle.
    ./drop-tentative-settings-constructor.patch
  ];

  prePatch = ''
    substitute ${./hardcode-gsettings.patch} hardcode-gsettings.patch \
      --subst-var-by EDS ${glib.makeSchemaPath "$out" "evolution-data-server-${finalAttrs.version}"} \
      --subst-var-by GDS ${glib.getSchemaPath gsettings-desktop-schemas}
    patches="$patches $PWD/hardcode-gsettings.patch"
  '';

  nativeBuildInputs = [
    cmake
    ninja
    pkg-config
    gettext
    python3
    gperf
    wrapGAppsHook3
    gobject-introspection
    vala
  ];

  buildInputs = [
    glib
    libsecret
    libsoup_3
    gnome-online-accounts
    p11-kit
    libgweather
    icu
    sqlite
    libkrb5
    openldap
    glib-networking
    libcanberra-gtk3
    libphonenumber
    libuuid
    boost
    protobuf
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    libiconv
  ]
  ++ lib.optionals withGtk3 [
    gtk3
  ]
  ++ lib.optionals (withGtk3 && enableOAuth2) [
    webkitgtk_4_1
  ]
  ++ lib.optionals withGtk4 [
    gtk4
  ]
  ++ lib.optionals (withGtk4 && enableOAuth2) [
    webkitgtk_6_0
  ];

  propagatedBuildInputs = [
    db
    nss
    nspr
    libical
    libsoup_3
    libxml2
    json-glib
  ];

  cmakeFlags = [
    "-DENABLE_VALA_BINDINGS=ON"
    "-DENABLE_INTROSPECTION=ON"
    "-DINCLUDE_INSTALL_DIR=${placeholder "dev"}/include"
    "-DWITH_PHONENUMBER=ON"
    "-DENABLE_GTK=${lib.boolToString withGtk3}"
    "-DENABLE_EXAMPLES=${lib.boolToString withGtk3}"
    "-DENABLE_CANBERRA=${lib.boolToString withGtk3}"
    "-DENABLE_GTK4=${lib.boolToString withGtk4}"
    "-DENABLE_OAUTH2_WEBKITGTK=${lib.boolToString (withGtk3 && enableOAuth2)}"
    "-DENABLE_OAUTH2_WEBKITGTK4=${lib.boolToString (withGtk4 && enableOAuth2)}"
  ]
  ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
    (lib.cmakeFeature "CMAKE_CROSSCOMPILING_EMULATOR" (stdenv.hostPlatform.emulator buildPackages))
  ];

  strictDeps = true;

  postPatch =
    lib.optionalString stdenv.hostPlatform.isDarwin ''
      substituteInPlace cmake/modules/SetupBuildFlags.cmake \
        --replace "-Wl,--no-undefined" ""
      substituteInPlace src/services/evolution-alarm-notify/e-alarm-notify.c \
        --replace "G_OS_WIN32" "__APPLE__"
    ''
    + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
      substituteInPlace src/addressbook/libebook-contacts/CMakeLists.txt --replace-fail \
        'COMMAND ''${CMAKE_CURRENT_BINARY_DIR}/gen-western-table' \
        'COMMAND ${stdenv.hostPlatform.emulator buildPackages} ''${CMAKE_CURRENT_BINARY_DIR}/gen-western-table'
      substituteInPlace src/camel/CMakeLists.txt --replace-fail \
        'COMMAND ''${CMAKE_CURRENT_BINARY_DIR}/camel-gen-tables' \
        'COMMAND ${stdenv.hostPlatform.emulator buildPackages} ''${CMAKE_CURRENT_BINARY_DIR}/camel-gen-tables'
    '';

  postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
    ln -s $out/lib/evolution-data-server/*.dylib $out/lib/
  '';

  passthru = {
    hardcodeGsettingsPatch = makeHardcodeGsettingsPatch {
      schemaIdToVariableMapping = {
        "org.gnome.Evolution.DefaultSources" = "EDS";
        "org.gnome.evolution.shell.network-config" = "EDS";
        "org.gnome.evolution-data-server.addressbook" = "EDS";
        "org.gnome.evolution-data-server.calendar" = "EDS";
        "org.gnome.evolution-data-server" = "EDS";
        "org.gnome.desktop.interface" = "GDS";
      };
      inherit (finalAttrs) src patches;
    };
    updateScript =
      let
        updateSource = gnome.updateScript {
          packageName = "evolution-data-server";
          versionPolicy = "odd-unstable";
        };
        updatePatch = _experimental-update-script-combinators.copyAttrOutputToFile "evolution-data-server.hardcodeGsettingsPatch" ./hardcode-gsettings.patch;
      in
      _experimental-update-script-combinators.sequence [
        updateSource
        updatePatch
      ];
  };

  meta = {
    description = "Unified backend for programs that work with contacts, tasks, and calendar information";
    homepage = "https://gitlab.gnome.org/GNOME/evolution-data-server";
    changelog = "https://gitlab.gnome.org/GNOME/evolution-data-server/-/blob/${finalAttrs.version}/NEWS?ref_type=tags";
    license = lib.licenses.lgpl2Plus;
    teams = [ lib.teams.gnome ];
    platforms = lib.platforms.linux; # requires libuuid
  };
})