From c6913213ebe7f584e7398e0f245905e00a1c1e41 Mon Sep 17 00:00:00 2001
From: Maximilian Bosch <maximilian@mbosch.me>
Date: Sun, 25 Nov 2018 21:26:25 +0100
Subject: [PATCH] nextcloud-client: switch to libsecret and use it by default

This change makes it easier for users to setup the nextcloud client with
GNOME keyring support as discussed in the IRC[1][2].

Additionaly we now use `libsecret` instead of `libgnome-keyring` which
integrates better in a GNOME setup (libgnome-keyring defaults to the
Gnome2 library)[3].

[1] https://logs.nix.samueldr.com/nixos/2018-11-24#1745871;
[2] https://logs.nix.samueldr.com/nixos/2018-11-24#1746033;
[3] #38266
---
 .../networking/nextcloud-client/default.nix        |  9 ++++++---
 .../networking/nextcloud-client/wrapper.nix        | 14 --------------
 pkgs/top-level/all-packages.nix                    |  6 +-----
 3 files changed, 7 insertions(+), 22 deletions(-)
 delete mode 100644 pkgs/applications/networking/nextcloud-client/wrapper.nix

diff --git a/pkgs/applications/networking/nextcloud-client/default.nix b/pkgs/applications/networking/nextcloud-client/default.nix
index 3d54ff3a7c34..ca1accf2f91b 100644
--- a/pkgs/applications/networking/nextcloud-client/default.nix
+++ b/pkgs/applications/networking/nextcloud-client/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchgit, cmake, pkgconfig, qtbase, qtwebkit, qtkeychain, qttools, sqlite
-, inotify-tools, makeWrapper, libgnome-keyring, openssl_1_1, pcre, qtwebengine
+, inotify-tools, makeWrapper, openssl_1_1, pcre, qtwebengine, libsecret
 }:
 
 stdenv.mkDerivation rec {
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
     fetchSubmodules = true;
   };
 
-  nativeBuildInputs = [ pkgconfig cmake ];
+  nativeBuildInputs = [ pkgconfig cmake makeWrapper ];
 
   buildInputs = [ qtbase qtwebkit qtkeychain qttools qtwebengine sqlite openssl_1_1.out pcre inotify-tools ];
 
@@ -32,7 +32,10 @@ stdenv.mkDerivation rec {
 
   postInstall = ''
     sed -i 's/\(Icon.*\)=nextcloud/\1=Nextcloud/g' \
-      $out/share/applications/nextcloud.desktop
+    $out/share/applications/nextcloud.desktop
+
+    wrapProgram "$out/bin/nextcloud" \
+      --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ libsecret ]}
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/applications/networking/nextcloud-client/wrapper.nix b/pkgs/applications/networking/nextcloud-client/wrapper.nix
deleted file mode 100644
index 292cbaa1c401..000000000000
--- a/pkgs/applications/networking/nextcloud-client/wrapper.nix
+++ /dev/null
@@ -1,14 +0,0 @@
-{ lib, nextcloud-client, makeWrapper, symlinkJoin, withGnomeKeyring ? false, libgnome-keyring }:
-
-if (!withGnomeKeyring) then nextcloud-client else symlinkJoin {
-  name = "${nextcloud-client.name}-with-gnome-keyring";
-  paths = [ nextcloud-client ];
-  nativeBuildInputs = [ makeWrapper ];
-
-  postBuild = ''
-    wrapProgram "$out/bin/nextcloud" \
-      --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libgnome-keyring ]}
-  '';
-
-  inherit (nextcloud-client) meta;
-}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 76f9067f787a..e956ca6ef3a0 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -4388,11 +4388,7 @@ with pkgs;
 
   nextcloud = callPackage ../servers/nextcloud { };
 
-  nextcloud-client-unwrapped = libsForQt5.callPackage ../applications/networking/nextcloud-client { };
-
-  nextcloud-client = callPackage ../applications/networking/nextcloud-client/wrapper.nix {
-    nextcloud-client = nextcloud-client-unwrapped;
-  };
+  nextcloud-client = libsForQt5.callPackage ../applications/networking/nextcloud-client { };
 
   nextcloud-news-updater = callPackage ../servers/nextcloud/news-updater.nix { };