about summary refs log tree commit diff
path: root/pkgs/applications/version-management
diff options
context:
space:
mode:
authorNoah Fontes <noah@noahfontes.com>2022-09-06 15:48:39 -0700
committerNoah Fontes <noah@noahfontes.com>2022-10-07 21:26:19 -0700
commit98d026a144d729d7054067cee6a57e6999d5c03f (patch)
tree82c0e5b2bda293ff31627cecc71d38dcc6e97ef7 /pkgs/applications/version-management
parenta8cf5d34970470bed49a336628c77a122cd4dc3b (diff)
p4v: use autoPatchelfHook, upstream libraries
P4V comes with a compatible set of Qt libraries that just need to be
patchelf'd to be usable, which avoids the need for the crypto hack we
were using. Switch to using autoPatchelfHook for all libraries, and
prefer the distribution's Qt libraries as part of that.

This also fixes a bug in the distributed version of p4d, which prevented
DVCS from working correctly in P4V.
Diffstat (limited to 'pkgs/applications/version-management')
-rw-r--r--pkgs/applications/version-management/p4v/default.nix115
1 files changed, 58 insertions, 57 deletions
diff --git a/pkgs/applications/version-management/p4v/default.nix b/pkgs/applications/version-management/p4v/default.nix
index b3b9bd77052a6..90e1e3af6256a 100644
--- a/pkgs/applications/version-management/p4v/default.nix
+++ b/pkgs/applications/version-management/p4v/default.nix
@@ -1,32 +1,33 @@
 { stdenv
 , fetchurl
 , lib
-, qtbase
+, autoPatchelfHook
+, cups
+, dbus
+, fontconfig
+, gccForLibs
+, libX11
+, libXcomposite
+, libXcursor
+, libXdamage
+, libXext
+, libXi
+, libXrandr
+, libXrender
+, libXtst
+, libinput
+, libxcb
+, libxkbcommon
+, nss
+, qttools
 , qtwebengine
-, qtdeclarative
-, qtwebchannel
-, syntax-highlighting
-, openssl
-, xkeyboard_config
-, patchelfUnstable
-, wrapQtAppsHook
-, writeText
+, xcbutilimage
+, xcbutilkeysyms
+, xcbutilrenderutil
+, xcbutilwm
 }:
-let
-  # This abomination exists because p4v calls CRYPTO_set_mem_functions and
-  # expects it to succeed. The function will fail if CRYPTO_malloc has already
-  # been called, which happens at init time via qtwebengine -> ... -> libssh. I
-  # suspect it was meant to work with a version of Qt where openssl is
-  # statically linked or some other library is used.
-  crypto-hack = writeText "crypto-hack.c" ''
-      #include <stddef.h>
-      int CRYPTO_set_mem_functions(
-            void *(*m)(size_t, const char *, int),
-            void *(*r)(void *, size_t, const char *, int),
-            void (*f)(void *, const char *, int)) { return 1; }
-    '';
 
-in stdenv.mkDerivation rec {
+stdenv.mkDerivation {
   pname = "p4v";
   version = "2022.2.2336701";
 
@@ -35,50 +36,50 @@ in stdenv.mkDerivation rec {
     sha256 = "8fdade4aafe25f568a61cfd80823aa90599c2a404b7c6b4a0862c84b07a9f8d2";
   };
 
-  dontBuild = true;
-  nativeBuildInputs = [ patchelfUnstable wrapQtAppsHook ];
-
-  ldLibraryPath = lib.makeLibraryPath [
-      stdenv.cc.cc.lib
-      qtbase
-      qtwebengine
-      qtdeclarative
-      qtwebchannel
-      syntax-highlighting
-      openssl
+  nativeBuildInputs = [ autoPatchelfHook ];
+  buildInputs = [
+    cups
+    dbus
+    fontconfig
+    gccForLibs
+    libX11
+    libXcomposite
+    libXcursor
+    libXdamage
+    libXext
+    libXi
+    libXrandr
+    libXrender
+    libXtst
+    libinput
+    libxcb
+    libxkbcommon
+    nss
+    qttools
+    qtwebengine
+    xcbutilimage
+    xcbutilkeysyms
+    xcbutilrenderutil
+    xcbutilwm
   ];
 
+  dontBuild = true;
+
+  # Don't wrap the Qt apps; upstream has its own wrapper scripts.
   dontWrapQtApps = true;
-  installPhase = ''
-    mkdir $out
-    cp -r bin $out
-    mkdir -p $out/lib
-    cp -r lib/P4VResources $out/lib
-    $CC -fPIC -shared -o $out/lib/libcrypto-hack.so ${crypto-hack}
 
-    for f in $out/bin/*.bin ; do
-      patchelf --set-rpath $ldLibraryPath --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $f
-      # combining this with above breaks rpath (patchelf bug?)
-      patchelf --add-needed libstdc++.so \
-               --add-needed $out/lib/libcrypto-hack.so \
-               --clear-symbol-version _ZNSt20bad_array_new_lengthD1Ev \
-               --clear-symbol-version _ZTVSt20bad_array_new_length \
-               --clear-symbol-version _ZTISt20bad_array_new_length \
-               --clear-symbol-version _ZdlPvm \
-               $f
-      wrapQtApp $f \
-        --suffix QT_XKB_CONFIG_ROOT : ${xkeyboard_config}/share/X11/xkb
-    done
+  installPhase = ''
+    mkdir -p $out
+    cp -r bin lib $out
+    addAutoPatchelfSearchPath $out/lib
   '';
 
-  dontFixup = true;
-
   meta = {
-    description = "Perforce Visual Client";
+    description = "Perforce Helix Visual Client";
     homepage = "https://www.perforce.com";
     sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
     license = lib.licenses.unfreeRedistributable;
     platforms = [ "x86_64-linux" ];
-    maintainers = with lib.maintainers; [ nathyong nioncode ];
+    maintainers = with lib.maintainers; [ impl nathyong nioncode ];
   };
 }