1{
2 lib,
3 _experimental-update-script-combinators,
4 curl,
5 darwin,
6 duktape,
7 fetchFromGitHub,
8 gi-docgen,
9 gitUpdater,
10 glib,
11 gobject-introspection,
12 gsettings-desktop-schemas,
13 makeHardcodeGsettingsPatch,
14 meson,
15 ninja,
16 pkg-config,
17 stdenv,
18 substituteAll,
19 vala,
20}:
21
22stdenv.mkDerivation (finalAttrs: {
23 pname = "libproxy";
24 version = "0.5.9";
25
26 outputs = [
27 "out"
28 "dev"
29 "devdoc"
30 ];
31
32 src = fetchFromGitHub {
33 owner = "libproxy";
34 repo = "libproxy";
35 rev = finalAttrs.version;
36 hash = "sha256-Z70TjLk5zulyYMAK+uMDhpsdvLa6m25pY8jahUA6ASE=";
37 };
38
39 patches =
40 [
41 ]
42 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
43 # Disable schema presence detection, it would fail because it cannot be autopatched,
44 # and it will be hardcoded by the next patch anyway.
45 ./skip-gsettings-detection.patch
46
47 # Hardcode path to Settings schemas for GNOME & related desktops.
48 # Otherwise every app using libproxy would need to be wrapped individually.
49 (substituteAll {
50 src = ./hardcode-gsettings.patch;
51 gds = glib.getSchemaPath gsettings-desktop-schemas;
52 })
53 ];
54
55 postPatch = ''
56 # Fix running script that will try to install git hooks.
57 # Though it will not do anything since we do not keep .git/ directory.
58 # https://github.com/libproxy/libproxy/issues/262
59 chmod +x data/install-git-hook.sh
60 patchShebangs data/install-git-hook.sh
61
62 # Fix include-path propagation in non-static builds.
63 # https://github.com/libproxy/libproxy/pull/239#issuecomment-2056620246
64 substituteInPlace src/libproxy/meson.build \
65 --replace-fail "requires_private: 'gobject-2.0'" "requires: 'gobject-2.0'"
66 '';
67
68 nativeBuildInputs = [
69 gi-docgen
70 gobject-introspection
71 meson
72 ninja
73 pkg-config
74 vala
75 ];
76
77 buildInputs =
78 [
79 curl
80 duktape
81 ]
82 ++ (
83 if stdenv.hostPlatform.isDarwin then
84 (with darwin.apple_sdk.frameworks; [
85 Foundation
86 ])
87 else
88 [
89 glib
90 gsettings-desktop-schemas
91 ]
92 );
93
94 mesonFlags =
95 [
96 # Prevent installing commit hook.
97 "-Drelease=true"
98 ]
99 ++ lib.optionals stdenv.hostPlatform.isDarwin [
100 "-Dconfig-gnome=false"
101 ];
102
103 doCheck = !stdenv.hostPlatform.isDarwin;
104
105 postFixup = ''
106 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
107 moveToOutput "share/doc" "$devdoc"
108 '';
109
110 passthru = {
111 hardcodeGsettingsPatch = makeHardcodeGsettingsPatch {
112 schemaIdToVariableMapping = {
113 "org.gnome.system.proxy" = "gds";
114 "org.gnome.system.proxy.http" = "gds";
115 "org.gnome.system.proxy.https" = "gds";
116 "org.gnome.system.proxy.ftp" = "gds";
117 "org.gnome.system.proxy.socks" = "gds";
118 };
119 inherit (finalAttrs) src;
120 };
121
122 updateScript =
123 let
124 updateSource = gitUpdater { };
125 updatePatch = _experimental-update-script-combinators.copyAttrOutputToFile "libproxy.hardcodeGsettingsPatch" ./hardcode-gsettings.patch;
126 in
127 _experimental-update-script-combinators.sequence [
128 updateSource
129 updatePatch
130 ];
131 };
132
133 meta = with lib; {
134 description = "Library that provides automatic proxy configuration management";
135 homepage = "https://libproxy.github.io/libproxy/";
136 license = licenses.lgpl21Plus;
137 platforms = platforms.linux ++ platforms.darwin;
138 mainProgram = "proxy";
139 };
140})