Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 88 additions & 49 deletions pkgs/development/libraries/libproxy/default.nix
Original file line number Diff line number Diff line change
@@ -1,83 +1,122 @@
{ lib
, stdenv
, _experimental-update-script-combinators
, curl
, darwin
, duktape
, fetchFromGitHub
, fetchpatch
, pkg-config
, cmake
, zlib
, dbus
, networkmanager
, enableJavaScript ? stdenv.isDarwin || lib.meta.availableOn stdenv.hostPlatform duktape
, duktape
, pcre
, gsettings-desktop-schemas
, gi-docgen
, gitUpdater
, glib
, makeWrapper
, python3
, SystemConfiguration
, CoreFoundation
, JavaScriptCore
, gobject-introspection
, gsettings-desktop-schemas
, makeHardcodeGsettingsPatch
, meson
, ninja
, pkg-config
, stdenv
, substituteAll
, vala
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "libproxy";
version = "0.4.18";
version = "0.5.3";

outputs = [ "out" "dev" "devdoc" ];

src = fetchFromGitHub {
owner = "libproxy";
repo = "libproxy";
rev = version;
hash = "sha256-pqj1LwRdOK2CUu3hYIsogQIXxWzShDuKEbDTbtWkgnQ=";
rev = finalAttrs.version;
hash = "sha256-qdYB6HJkgboS8kkTvTqLy6Z3JYY5SOJsRl6nZM0iuvw=";
};

patches = lib.optionals stdenv.isDarwin [
# https://github.com/libproxy/libproxy/pull/189
patches = [
# Minor refactoring. Allows the following patches to apply without rebasing.
(fetchpatch {
url = "https://github.com/libproxy/libproxy/commit/4331b9db427ce2c25ff5eeb597bec4bc35ed1a0b.patch";
sha256 = "sha256-uTh3rYVvEke1iWVHsT3Zj2H1F+gyLrffcmyt0JEKaCA=";
url = "https://github.com/libproxy/libproxy/commit/397f4dc72607cc1bb3b584ffd3de49f8ba80491a.patch";
hash = "sha256-iUMBMpcVOLG+NxEj8Nd7JtKZFmoGXn0t6A2r2ayiteg=";
includes = [
"src/backend/plugins/config-gnome/config-gnome.c"
];
})
];

outputs = [ "out" "dev" "py3" ];
# Disable schema presence detection, it would fail because it cannot be autopatched,
# and it will be hardcoded by the next patch anyway.
./skip-gsettings-detection.patch

# Hardcode path to Settings schemas for GNOME & related desktops.
# Otherwise every app using libproxy would need to be wrapped individually.
(substituteAll {
src = ./hardcode-gsettings.patch;
gds = glib.getSchemaPath gsettings-desktop-schemas;
})
];

nativeBuildInputs = [
gi-docgen
gobject-introspection
meson
ninja
pkg-config
cmake
makeWrapper
vala
];

buildInputs = [
pcre
python3
zlib
] ++ lib.optionals enableJavaScript [
(if stdenv.hostPlatform.isDarwin then JavaScriptCore else duktape)
] ++ (if stdenv.hostPlatform.isDarwin then [
SystemConfiguration
curl
duktape
] ++ (if stdenv.hostPlatform.isDarwin then (with darwin.apple_sdk.frameworks; [
CoreFoundation
] else [
SystemConfiguration
]) else [
glib
dbus
networkmanager
gsettings-desktop-schemas
]);

cmakeFlags = [
"-DWITH_PYTHON2=OFF"
"-DPYTHON3_SITEPKG_DIR=${placeholder "py3"}/${python3.sitePackages}"
] ++ lib.optional (enableJavaScript && !stdenv.hostPlatform.isDarwin) "-DWITH_MOZJS=ON";
doCheck = true;

postFixup = lib.optionalString stdenv.isLinux ''
# config_gnome3 uses the helper to find GNOME proxy settings
wrapProgram $out/libexec/pxgsettings --prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this still looks for GNOME settings, either a wrapper or patch (see makeHardcodeGsettingsPatch) will still be necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pxgsettings no longer exists.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😒 libproxy/libproxy@3e06882

The new location seems to be https://github.com/libproxy/libproxy/tree/main/src/backend/plugins/config-gnome .

No idea if we need to wrap the proxy binary instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proxy program is just a test tool so wrapping it will not help. Looks like the backends are all compiled into libpxbackend.

The only option is patching it as in #271037

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do we now wait for that PR or just hope people wrap?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That PR only affects GTK. I meant is as an example what would have to be done here if we do not want even more wrappers everywhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no experience with C/C++, so that would need to be done by someone else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed a patch + update script to update it (depends on #276828). The patch is suboptimal for now (the source is created multiple times) but at least it can be generated automatically.

postPatch = ''
# Fix running script that will try to install git hooks.
# Though it will not do anything since we do not keep .git/ directory.
# https://github.com/libproxy/libproxy/issues/262
chmod +x data/install-git-hook.sh
patchShebangs data/install-git-hook.sh
'';

doCheck = false; # fails 1 out of 10 tests
postFixup = ''
# Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
moveToOutput "share/doc" "$devdoc"
'';

passthru = {
hardcodeGsettingsPatch = makeHardcodeGsettingsPatch {
schemaIdToVariableMapping = {
"org.gnome.system.proxy" = "gds";
"org.gnome.system.proxy.http" = "gds";
"org.gnome.system.proxy.https" = "gds";
"org.gnome.system.proxy.ftp" = "gds";
"org.gnome.system.proxy.socks" = "gds";
};
inherit (finalAttrs) src;
};

updateScript =
let
updateSource = gitUpdater { };
updatePatch = _experimental-update-script-combinators.copyAttrOutputToFile "libproxy.hardcodeGsettingsPatch" ./hardcode-gsettings.patch;
in
_experimental-update-script-combinators.sequence [
updateSource
updatePatch
];
};

meta = with lib; {
platforms = platforms.linux ++ platforms.darwin;
license = licenses.lgpl21;
homepage = "https://libproxy.github.io/libproxy/";
description = "A library that provides automatic proxy configuration management";
homepage = "https://libproxy.github.io/libproxy/";
license = licenses.lgpl21Plus;
platforms = platforms.linux ++ platforms.darwin;
mainProgram = "proxy";
};
}
})
140 changes: 140 additions & 0 deletions pkgs/development/libraries/libproxy/hardcode-gsettings.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
diff --git a/src/backend/plugins/config-gnome/config-gnome.c b/src/backend/plugins/config-gnome/config-gnome.c
index 820827b..338e269 100644
--- a/src/backend/plugins/config-gnome/config-gnome.c
+++ b/src/backend/plugins/config-gnome/config-gnome.c
@@ -85,11 +85,60 @@ px_config_gnome_init (PxConfigGnome *self)
if (!self->available)
return;

- self->proxy_settings = g_settings_new ("org.gnome.system.proxy");
- self->http_proxy_settings = g_settings_new ("org.gnome.system.proxy.http");
- self->https_proxy_settings = g_settings_new ("org.gnome.system.proxy.https");
- self->ftp_proxy_settings = g_settings_new ("org.gnome.system.proxy.ftp");
- self->socks_proxy_settings = g_settings_new ("org.gnome.system.proxy.socks");
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ "org.gnome.system.proxy", FALSE);
+ self->proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ }
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ "org.gnome.system.proxy.http",
+ FALSE);
+ self->http_proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ }
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ "org.gnome.system.proxy.https",
+ FALSE);
+ self->https_proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ }
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ "org.gnome.system.proxy.ftp",
+ FALSE);
+ self->ftp_proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ }
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ "org.gnome.system.proxy.socks",
+ FALSE);
+ self->socks_proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ }
}

static void
diff --git a/tests/config-gnome-test.c b/tests/config-gnome-test.c
index f80914a..118d429 100644
--- a/tests/config-gnome-test.c
+++ b/tests/config-gnome-test.c
@@ -60,11 +60,60 @@ static void
fixture_setup (Fixture *self,
gconstpointer data)
{
- self->proxy_settings = g_settings_new ("org.gnome.system.proxy");
- self->http_proxy_settings = g_settings_new ("org.gnome.system.proxy.http");
- self->https_proxy_settings = g_settings_new ("org.gnome.system.proxy.https");
- self->ftp_proxy_settings = g_settings_new ("org.gnome.system.proxy.ftp");
- self->socks_proxy_settings = g_settings_new ("org.gnome.system.proxy.socks");
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ "org.gnome.system.proxy", FALSE);
+ self->proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ }
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ "org.gnome.system.proxy.http",
+ FALSE);
+ self->http_proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ }
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ "org.gnome.system.proxy.https",
+ FALSE);
+ self->https_proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ }
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ "org.gnome.system.proxy.ftp",
+ FALSE);
+ self->ftp_proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ }
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ "org.gnome.system.proxy.socks",
+ FALSE);
+ self->socks_proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ }
}

static void
29 changes: 29 additions & 0 deletions pkgs/development/libraries/libproxy/skip-gsettings-detection.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/src/backend/plugins/config-gnome/config-gnome.c b/src/backend/plugins/config-gnome/config-gnome.c
index 52e812e..a1edcab 100644
--- a/src/backend/plugins/config-gnome/config-gnome.c
+++ b/src/backend/plugins/config-gnome/config-gnome.c
@@ -57,7 +57,6 @@ enum {
static void
px_config_gnome_init (PxConfigGnome *self)
{
- GSettingsSchemaSource *source;
g_autoptr (GSettingsSchema) proxy_schema = NULL;
const char *desktops;

@@ -71,15 +70,7 @@ px_config_gnome_init (PxConfigGnome *self)
if (strstr (desktops, "GNOME") == NULL)
return;

- source = g_settings_schema_source_get_default ();
- if (!source) {
- g_warning ("GNOME desktop detected but no schemes installed, aborting.");
- return;
- }
-
- proxy_schema = g_settings_schema_source_lookup (source, "org.gnome.system.proxy", TRUE);
-
- self->available = proxy_schema != NULL;
+ self->available = TRUE;
if (!self->available)
return;

4 changes: 1 addition & 3 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22971,9 +22971,7 @@ with pkgs;
stdenv = gccStdenv; # Required for darwin
}) libprom libpromhttp;

libproxy = callPackage ../development/libraries/libproxy {
inherit (darwin.apple_sdk.frameworks) SystemConfiguration CoreFoundation JavaScriptCore;
};
libproxy = callPackage ../development/libraries/libproxy { };

libpseudo = callPackage ../development/libraries/libpseudo { };

Expand Down