1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, pkg-config
6, cmake
7, zlib
8, dbus
9, networkmanager
10, enableJavaScript ? stdenv.isDarwin || lib.meta.availableOn stdenv.hostPlatform duktape
11, duktape
12, pcre
13, gsettings-desktop-schemas
14, glib
15, makeWrapper
16, python3
17, SystemConfiguration
18, CoreFoundation
19, JavaScriptCore
20}:
21
22stdenv.mkDerivation rec {
23 pname = "libproxy";
24 version = "0.4.18";
25
26 src = fetchFromGitHub {
27 owner = "libproxy";
28 repo = "libproxy";
29 rev = version;
30 hash = "sha256-pqj1LwRdOK2CUu3hYIsogQIXxWzShDuKEbDTbtWkgnQ=";
31 };
32
33 patches = lib.optionals stdenv.isDarwin [
34 # https://github.com/libproxy/libproxy/pull/189
35 (fetchpatch {
36 url = "https://github.com/libproxy/libproxy/commit/4331b9db427ce2c25ff5eeb597bec4bc35ed1a0b.patch";
37 sha256 = "sha256-uTh3rYVvEke1iWVHsT3Zj2H1F+gyLrffcmyt0JEKaCA=";
38 })
39 ];
40
41 outputs = [ "out" "dev" "py3" ];
42
43 nativeBuildInputs = [
44 pkg-config
45 cmake
46 makeWrapper
47 ];
48
49 buildInputs = [
50 pcre
51 python3
52 zlib
53 ] ++ lib.optionals enableJavaScript [
54 (if stdenv.hostPlatform.isDarwin then JavaScriptCore else duktape)
55 ] ++ (if stdenv.hostPlatform.isDarwin then [
56 SystemConfiguration
57 CoreFoundation
58 ] else [
59 glib
60 dbus
61 networkmanager
62 ]);
63
64 cmakeFlags = [
65 "-DWITH_PYTHON2=OFF"
66 "-DPYTHON3_SITEPKG_DIR=${placeholder "py3"}/${python3.sitePackages}"
67 ] ++ lib.optional (enableJavaScript && !stdenv.hostPlatform.isDarwin) "-DWITH_MOZJS=ON";
68
69 postFixup = lib.optionalString stdenv.isLinux ''
70 # config_gnome3 uses the helper to find GNOME proxy settings
71 wrapProgram $out/libexec/pxgsettings --prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
72 '';
73
74 doCheck = false; # fails 1 out of 10 tests
75
76 meta = with lib; {
77 platforms = platforms.linux ++ platforms.darwin;
78 license = licenses.lgpl21;
79 homepage = "http://libproxy.github.io/libproxy/";
80 description = "A library that provides automatic proxy configuration management";
81 };
82}