Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextcloud-client/owncloud-client/qtkeychain: Fix GNOME keyring integration #71874

Closed
wants to merge 3 commits into from

Conversation

puppe
Copy link
Contributor

@puppe puppe commented Oct 23, 2019

Motivation for this change

There had been a small mistake in the package definition of qtkeychain. The result had been that qtkeychain was being compiled without libsecret support. Therefore, integration with the GNOME keyring had not been working, forcing users to put in credentials whenever they started the clients for Nextcloud or Owncloud.

This pull request takes care that qtkeychain can be built with libsecret support. qtkeychain now has an option called withLibsecret which defaults to false. For nextcloud-client and owncloud-client, qtkeychain is built with withLibsecret = true.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS (qtkeychain only)
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @caugner @Ma27 @qknight

Because of a small mistake in the use of lib.lists.optional [^1],
libsecret was not being used during the build of qtkeychain. This commit
fixes that mistake. But since including libsecret apparently breaks some
packages, this commit makes the inclusion of libsecret optional via the
withLibsecret option, which defaults to false. Therefore, this change
should be free of any consequences.

Note that this commit also changes one occurrence of lib.lists.optional
that is used for Darwin-specific buildInputs. I have tested (with
nix-review) whether this breaks anything on macOS. Everything seems to
be fine. The output of nix-review has been: “Nothing changed."

[^1]: lib.lists.optional wraps its input in a list. Therefore, the argument to
this function should usually not be a list because then the result is a
nested list, which is, in most cases, not the desired output.
lib.lists.optionals — note the ’s’ at the end — on the other hand does
not wrap its input in a list.
This change enables integration with the GNOME keyring. See commit
c691321 [^1] and the current derivation
of nextcloud-client [^2] for comparison.

[^1]: c691321
[^2]: https://github.com/NixOS/nixpkgs/blob/8825940cec53cdd300186110acb6a51895ecd4f9/pkgs/applications/networking/nextcloud-client/default.nix
nextcloud-client now *actually* uses libsecret (via qtkeychain), which
enables integration with the GNOME keyring for real this time.
@teto
Copy link
Member

teto commented Oct 24, 2019

Should be unrelated but seems like the client has trouble blitting its window,
it remains empty sometimes.

@jtojnar
Copy link
Contributor

jtojnar commented Oct 24, 2019

As discussed n one of the previous PRs, we should build with libsecret support by default, unconditionally.

@puppe
Copy link
Contributor Author

puppe commented Oct 24, 2019

Should be unrelated but seems like the client has trouble blitting its window,
it remains empty sometimes.

I doubt that has anything to do with my pull request. Could you please check whether you also have this problem on the master branch?

As discussed n one of the previous PRs, we should build with libsecret support by default, unconditionally.

Enabling libsecret by default breaks the following packages: matrique/spectral-unstable, psi-plus, quaternion, trojita. I did not want to introduce a breaking change, and I did not want to touch unrelated packages. That's why I did it this way. I see two alternatives to my solution:

  1. Change the default of withLibsecret to true.
  2. Always build qtkeychain with libsecret. No withLibsecret option.

With alternative 1, one could change the breaking packages to withLibsecret = false. I could do that, if you want. Alternative 2 means breaking these four packages. Someone would have to fix them.

How do we proceed?

PS: This is my first contribution to NixOS.

@jtojnar
Copy link
Contributor

jtojnar commented Oct 27, 2019

Could you share the failure logs? Are they really caused by this?

diff --git a/pkgs/development/libraries/qtkeychain/default.nix b/pkgs/development/libraries/qtkeychain/default.nix
index 3de84d85911..31b944e6611 100644
--- a/pkgs/development/libraries/qtkeychain/default.nix
+++ b/pkgs/development/libraries/qtkeychain/default.nix
@@ -21,7 +21,10 @@
 
   patches = if withQt5 then null else [ ./0001-Fixes-build-with-Qt4.patch ];
 
-  cmakeFlags = [ "-DQT_TRANSLATIONS_DIR=share/qt/translations" ];
+  cmakeFlags = [
+    "-DQT_TRANSLATIONS_DIR=share/qt/translations"
+    "-DLIBSECRET_SUPPORT=ON"
+  ];
 
   nativeBuildInputs = [ cmake ]
     ++ stdenv.lib.optional (!stdenv.isDarwin) [ pkgconfig ] # for finding libsecret

seems to be a no-op, so I do not see how it could break anything.

@puppe
Copy link
Contributor Author

puppe commented Oct 28, 2019

The lines that you quoted only are there so that no error messages are shown if libsecret isn't found. The really relevant change is this:

-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin) [ libsecret ]
+  buildInputs = stdenv.lib.optionals useLibsecret [ libsecret ]

Note the use of stdenv.lib.optionals instead of stdenv.lib.optional. The same effect could have been achieved by the following change:

-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin) [ libsecret ]
+  buildInputs = stdenv.lib.optional useLibsecret libsecret

To quote from my commit message:

lib.lists.optional wraps its input in a list. Therefore, the argument to
this function should usually not be a list because then the result is a
nested list, which is, in most cases, not the desired output.
lib.lists.optionals — note the ’s’ at the end — on the other hand does
not wrap its input in a list.

libsecret had never actually been used. When it is used by default, some package builds break. psi-plus, for example:

…
[ 95%] Linking CXX executable ../psi/psi-plus
/nix/store/cg0k49h66nkdqx6ccwnqr0i4q0fnfznc-binutils-2.31.1/bin/ld: cannot find -lsecret-1
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/psi-plus.dir/build.make:3639: psi/psi-plus] Error 1
make[1]: *** [CMakeFiles/Makefile2:379: src/CMakeFiles/psi-plus.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
…

@jtojnar
Copy link
Contributor

jtojnar commented Oct 28, 2019

Note the use of stdenv.lib.optionals instead of stdenv.lib.optional.

You are right, I was missing this. We should really have something checking for this.

libsecret had never actually been used.

I believe we built it with the support for libsecret (if it were not found, it would fail) but, since it was not linked against, we had to manually override the linking. Now that it is linked against it, we should be able to drop the LD_LIBRARY_PATH.

When it is used by default, some package builds break.

It is caused by this change:

--- /nix/store/bkfwmwzl9iyfmq6r5kx3sk3pin1h4rys-qtkeychain-qt5-0.9.1/lib/cmake/Qt5Keychain/Qt5KeychainLibraryDepends-release.cmake
+++ /nix/store/nh2qv2m9bmbf6jyb7753zhk6nlx62da1-qtkeychain-qt5-0.9.1/lib/cmake/Qt5Keychain/Qt5KeychainLibraryDepends-release.cmake
@@ -8,9 +8,9 @@
 # Import target "qt5keychain" for configuration "Release"
 set_property(TARGET qt5keychain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
 set_target_properties(qt5keychain PROPERTIES
-  IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "Qt5::Core;Qt5::DBus"
-  IMPORTED_LOCATION_RELEASE "/nix/store/bkfwmwzl9iyfmq6r5kx3sk3pin1h4rys-qtkeychain-qt5-0.9.1/lib/libqt5keychain.so.0.9.1"
+  IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "Qt5::Core;secret-1;gio-2.0;gobject-2.0;glib-2.0;Qt5::DBus"
+  IMPORTED_LOCATION_RELEASE "/nix/store/nh2qv2m9bmbf6jyb7753zhk6nlx62da1-qtkeychain-qt5-0.9.1/lib/libqt5keychain.so.0.9.1"
   IMPORTED_SONAME_RELEASE "libqt5keychain.so.1"
   )
 
 list(APPEND _IMPORT_CHECK_TARGETS qt5keychain )

I would say it is because the upstream incorrectly marks the library dependencies. frankosterfeld/qtkeychain#153 should fix that:

--- a/pkgs/development/libraries/qtkeychain/default.nix
+++ b/pkgs/development/libraries/qtkeychain/default.nix
@@ -1,4 +1,7 @@
-{ stdenv, fetchFromGitHub, cmake, pkgconfig, qt4 ? null
+{ stdenv
+, fetchFromGitHub
+, fetchpatch
+, cmake, pkgconfig, qt4 ? null
 , withQt5 ? false, qtbase ? null, qttools ? null
 , darwin ? null
 , libsecret
@@ -19,7 +22,16 @@
     sha256 = "0h4wgngn2yl35hapbjs24amkjfbzsvnna4ixfhn87snjnq5lmjbc"; # v0.9.1
   };
 
-  patches = if withQt5 then null else [ ./0001-Fixes-build-with-Qt4.patch ];
+  patches = [
+    # Do not propagate internal dependency on libsecret.
+    # https://github.com/frankosterfeld/qtkeychain/pull/153
+    (fetchpatch {
+      url = "https://github.com/frankosterfeld/qtkeychain/commit/94d719168f874c07a1edfb1aca7e21875063b292.patch";
+      sha256 = "1mz72xalmsy336xijazlh8ffzsaqag2pch6mg8pgxiq7xy31fvxk";
+    })
+  ] ++ stdenv.lib.optionals (!withQt5) [
+    ./0001-Fixes-build-with-Qt4.patch
+  ];
 
   cmakeFlags = [ "-DQT_TRANSLATIONS_DIR=share/qt/translations" ];
 

@vegaelle
Copy link

vegaelle commented Mar 3, 2020

Hi. Is there any news on this PR?

@puppe
Copy link
Contributor Author

puppe commented Mar 4, 2020

Hi. Is there any news on this PR?

Yeah. I just checked with the current master. The Nextcloud and Owncloud clients work fine now. This has been fixed with commit 839c0ea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants