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.

+58 -57
+58 -57
pkgs/applications/version-management/p4v/default.nix
··· 1 1 { stdenv 2 2 , fetchurl 3 3 , lib 4 - , qtbase 4 + , autoPatchelfHook 5 + , cups 6 + , dbus 7 + , fontconfig 8 + , gccForLibs 9 + , libX11 10 + , libXcomposite 11 + , libXcursor 12 + , libXdamage 13 + , libXext 14 + , libXi 15 + , libXrandr 16 + , libXrender 17 + , libXtst 18 + , libinput 19 + , libxcb 20 + , libxkbcommon 21 + , nss 22 + , qttools 5 23 , qtwebengine 6 - , qtdeclarative 7 - , qtwebchannel 8 - , syntax-highlighting 9 - , openssl 10 - , xkeyboard_config 11 - , patchelfUnstable 12 - , wrapQtAppsHook 13 - , writeText 24 + , xcbutilimage 25 + , xcbutilkeysyms 26 + , xcbutilrenderutil 27 + , xcbutilwm 14 28 }: 15 - let 16 - # This abomination exists because p4v calls CRYPTO_set_mem_functions and 17 - # expects it to succeed. The function will fail if CRYPTO_malloc has already 18 - # been called, which happens at init time via qtwebengine -> ... -> libssh. I 19 - # suspect it was meant to work with a version of Qt where openssl is 20 - # statically linked or some other library is used. 21 - crypto-hack = writeText "crypto-hack.c" '' 22 - #include <stddef.h> 23 - int CRYPTO_set_mem_functions( 24 - void *(*m)(size_t, const char *, int), 25 - void *(*r)(void *, size_t, const char *, int), 26 - void (*f)(void *, const char *, int)) { return 1; } 27 - ''; 28 29 29 - in stdenv.mkDerivation rec { 30 + stdenv.mkDerivation { 30 31 pname = "p4v"; 31 32 version = "2022.2.2336701"; 32 33 ··· 35 36 sha256 = "8fdade4aafe25f568a61cfd80823aa90599c2a404b7c6b4a0862c84b07a9f8d2"; 36 37 }; 37 38 38 - dontBuild = true; 39 - nativeBuildInputs = [ patchelfUnstable wrapQtAppsHook ]; 39 + nativeBuildInputs = [ autoPatchelfHook ]; 40 + buildInputs = [ 41 + cups 42 + dbus 43 + fontconfig 44 + gccForLibs 45 + libX11 46 + libXcomposite 47 + libXcursor 48 + libXdamage 49 + libXext 50 + libXi 51 + libXrandr 52 + libXrender 53 + libXtst 54 + libinput 55 + libxcb 56 + libxkbcommon 57 + nss 58 + qttools 59 + qtwebengine 60 + xcbutilimage 61 + xcbutilkeysyms 62 + xcbutilrenderutil 63 + xcbutilwm 64 + ]; 40 65 41 - ldLibraryPath = lib.makeLibraryPath [ 42 - stdenv.cc.cc.lib 43 - qtbase 44 - qtwebengine 45 - qtdeclarative 46 - qtwebchannel 47 - syntax-highlighting 48 - openssl 49 - ]; 66 + dontBuild = true; 50 67 68 + # Don't wrap the Qt apps; upstream has its own wrapper scripts. 51 69 dontWrapQtApps = true; 70 + 52 71 installPhase = '' 53 - mkdir $out 54 - cp -r bin $out 55 - mkdir -p $out/lib 56 - cp -r lib/P4VResources $out/lib 57 - $CC -fPIC -shared -o $out/lib/libcrypto-hack.so ${crypto-hack} 58 - 59 - for f in $out/bin/*.bin ; do 60 - patchelf --set-rpath $ldLibraryPath --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $f 61 - # combining this with above breaks rpath (patchelf bug?) 62 - patchelf --add-needed libstdc++.so \ 63 - --add-needed $out/lib/libcrypto-hack.so \ 64 - --clear-symbol-version _ZNSt20bad_array_new_lengthD1Ev \ 65 - --clear-symbol-version _ZTVSt20bad_array_new_length \ 66 - --clear-symbol-version _ZTISt20bad_array_new_length \ 67 - --clear-symbol-version _ZdlPvm \ 68 - $f 69 - wrapQtApp $f \ 70 - --suffix QT_XKB_CONFIG_ROOT : ${xkeyboard_config}/share/X11/xkb 71 - done 72 + mkdir -p $out 73 + cp -r bin lib $out 74 + addAutoPatchelfSearchPath $out/lib 72 75 ''; 73 76 74 - dontFixup = true; 75 - 76 77 meta = { 77 - description = "Perforce Visual Client"; 78 + description = "Perforce Helix Visual Client"; 78 79 homepage = "https://www.perforce.com"; 79 80 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 80 81 license = lib.licenses.unfreeRedistributable; 81 82 platforms = [ "x86_64-linux" ]; 82 - maintainers = with lib.maintainers; [ nathyong nioncode ]; 83 + maintainers = with lib.maintainers; [ impl nathyong nioncode ]; 83 84 }; 84 85 }