about summary refs log tree commit diff
path: root/pkgs/development/libraries/webkitgtk
diff options
context:
space:
mode:
authorzseri <zseri.devel@ytrizja.de>2021-12-02 09:38:13 +0100
committerzseri <zseri.devel@ytrizja.de>2022-02-23 23:38:05 +0100
commitbed1ee054887e0d23f75a55afc5d497c71a6a09c (patch)
tree02acb3669d0af55224e4c989d37774590fc38e66 /pkgs/development/libraries/webkitgtk
parent9a93279738708df0801185a35fb31671b4616b70 (diff)
webkitgtk: make it easier to disable avahi globally by fixing enableGeoLocation option
The problem with enableGeoLocation was that it didn't compose well with
.overrideAttrs and setting geoclue2=null at the overlay level
because of the assert statement.

Thus, when combined with disabling libsecret, the resulting override code was:
  avahi = null;
  geoclue2 = { outPath = throw "geoclue is disabled"; };
  webkitgtk = prev.lib.pipe prev.webkitgtk [
    (x: x.override { enableGeoLocation = false; geoclue2 = prev.geoclue2; })
    (x: x.overrideAttrs (old: { cmakeFlags = old.cmakeFlags ++ [ "-DUSE_LIBSECRET=OFF" ]; }))
    (x: x.override { enableGeoLocation = false; geoclue2 = null; libsecret = null; })
  ];

It works, but is unnecessarily complex.

: detailed motviation
libsecret and geoclue2 are actually completely independent,
the real conflict is between assert and override/overrideAttrs which
don't work as expected; e.g. you can pass an updated parameter, but the
original parameter at callPackage "calltime" after recusion through overlays
gets used, so when globally setting "geoclue2=null;" in an overlay,
the assert is always hit without any way to work around that
Diffstat (limited to 'pkgs/development/libraries/webkitgtk')
-rw-r--r--pkgs/development/libraries/webkitgtk/default.nix32
1 files changed, 19 insertions, 13 deletions
diff --git a/pkgs/development/libraries/webkitgtk/default.nix b/pkgs/development/libraries/webkitgtk/default.nix
index b5a16df21add6..92405b35de294 100644
--- a/pkgs/development/libraries/webkitgtk/default.nix
+++ b/pkgs/development/libraries/webkitgtk/default.nix
@@ -1,4 +1,5 @@
-{ lib, stdenv
+{ lib
+, stdenv
 , runCommand
 , fetchurl
 , perl
@@ -44,7 +45,6 @@
 , lcms2
 , libmanette
 , openjpeg
-, enableGeoLocation ? true
 , geoclue2
 , sqlite
 , enableGLES ? true
@@ -58,10 +58,10 @@
 , substituteAll
 , glib
 , addOpenGLRunpath
+, enableGeoLocation ? true
+, withLibsecret ? true
 }:
 
-assert enableGeoLocation -> geoclue2 != null;
-
 stdenv.mkDerivation rec {
   pname = "webkitgtk";
   version = "2.34.6";
@@ -125,12 +125,8 @@ stdenv.mkDerivation rec {
     libidn
     libintl
     lcms2
-  ] ++ lib.optionals stdenv.isLinux [
-    libmanette
-  ] ++ [
     libnotify
     libpthreadstubs
-    libsecret
     libtasn1
     libwebp
     libxkbcommon
@@ -155,28 +151,36 @@ stdenv.mkDerivation rec {
     # (We pick just that one because using the other headers from `sdk` is not
     # compatible with our C++ standard library. This header is already in
     # the standard library on aarch64)
-    runCommand "${pname}_headers" {} ''
+    runCommand "${pname}_headers" { } ''
       install -Dm444 "${lib.getDev apple_sdk.sdk}"/include/libproc.h "$out"/include/libproc.h
     ''
   ) ++ lib.optionals stdenv.isLinux [
     bubblewrap
     libseccomp
+    libmanette
     systemd
     wayland
     xdg-dbus-proxy
-  ] ++ lib.optional enableGeoLocation geoclue2;
+  ] ++ lib.optionals enableGeoLocation [
+    geoclue2
+  ] ++ lib.optionals withLibsecret [
+    libsecret
+  ];
 
   propagatedBuildInputs = [
     gtk3
     libsoup
   ];
 
-  cmakeFlags = [
+  cmakeFlags = let
+    cmakeBool = x: if x then "ON" else "OFF";
+  in [
     "-DENABLE_INTROSPECTION=ON"
     "-DPORT=GTK"
     "-DUSE_LIBHYPHEN=OFF"
     "-DUSE_WPE_RENDERER=OFF"
-    "-DUSE_SOUP2=${if lib.versions.major libsoup.version == "2" then "ON" else "OFF"}"
+    "-DUSE_SOUP2=${cmakeBool (lib.versions.major libsoup.version == "2")}"
+    "-DUSE_LIBSECRET=${cmakeBool withLibsecret}"
   ] ++ lib.optionals stdenv.isDarwin [
     "-DENABLE_GAMEPAD=OFF"
     "-DENABLE_GTKDOC=OFF"
@@ -191,7 +195,9 @@ stdenv.mkDerivation rec {
     "-DUSE_SYSTEM_MALLOC=ON"
   ] ++ lib.optionals (!stdenv.isLinux) [
     "-DUSE_SYSTEMD=OFF"
-  ] ++ lib.optional (stdenv.isLinux && enableGLES) "-DENABLE_GLES2=ON";
+  ] ++ lib.optionals (stdenv.isLinux && enableGLES) [
+    "-DENABLE_GLES2=ON"
+  ];
 
   postPatch = ''
     patchShebangs .