16 opensslStatic = openssl.override {
22 url = "https://android.googlesource.com/platform/external/zlib/+archive/61174f4fd262c6075f88768465f308aae95a2f04.tar.gz";
23 sha256 = "sha256-EMzKAHcEWOUugcHKH2Fj3ZaIHC9UlgO4ULKe3RvgxvI=";
27 linkFarm "android-zlib-contrib" [
28 # We only want to keep the contrib directory as the other files conflict
29 # with p4's own zlib files. (For the same reason, we can't use the
30 # cone-based Git sparse checkout, either.)
31 { name = "contrib"; path = "${src}/contrib"; }
34 stdenv.mkDerivation (finalAttrs: rec {
36 version = "2024.1/2596294";
39 # Upstream replaces minor versions, so use archived URL.
40 url = "https://web.archive.org/web/20240526153453id_/https://ftp.perforce.com/perforce/r24.1/bin.tools/p4source.tgz";
41 sha256 = "sha256-6+DOJPeVzP4x0UsN9MlZRAyusapBTICX0BuyvVBQBC8=";
44 nativeBuildInputs = [ jam ];
46 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ CoreServices Foundation Security ];
48 outputs = [ "out" "bin" "dev" ];
50 hardeningDisable = lib.optionals stdenv.hostPlatform.isDarwin [ "strictoverflow" ];
55 "-sCROSS_COMPILE=${stdenv.cc.targetPrefix}"
56 "-sMALLOC_OVERRIDE=no"
57 "-sSSLINCDIR=${lib.getDev opensslStatic}/include"
58 "-sSSLLIBDIR=${lib.getLib opensslStatic}/lib"
60 ++ lib.optionals stdenv.cc.isClang [ "-sOSCOMP=clang" "-sCLANGVER=${stdenv.cc.cc.version}" ]
61 ++ lib.optionals stdenv.cc.isGNU [ "-sOSCOMP=gcc" "-sGCCVER=${stdenv.cc.cc.version}" ]
62 ++ lib.optionals stdenv.hostPlatform.isLinux [ "-sOSVER=26" ]
63 ++ lib.optionals stdenv.hostPlatform.isDarwin [
65 "-sMACOSX_SDK=${emptyDirectory}"
66 "-sLIBC++DIR=${lib.getLib stdenv.cc.libcxx}/lib"
70 # The file contrib/optimizations/slide_hash_neon.h is missing from the
71 # upstream distribution. It comes from the Android/Chromium sources.
72 lib.optionals stdenv.hostPlatform.isAarch64 [ "-I${androidZlibContrib}" ];
75 # Avoid a compilation error that only occurs for 4-byte longs.
76 lib.optionals stdenv.hostPlatform.isi686 [ "-Wno-narrowing" ]
77 # See the "Header dependency changes" section of
78 # https://www.gnu.org/software/gcc/gcc-11/porting_to.html for more
79 # information on why we need to include these.
81 (stdenv.cc.isClang || (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.cc.version "11.0.0"))
82 [ "-include" "limits" "-include" "thread" ];
86 jam $jamFlags -j$NIX_BUILD_CORES p4
87 jam $jamFlags -j$NIX_BUILD_CORES -sPRODUCTION=yes p4api.tar
93 mkdir -p $bin/bin $dev $out
94 cp bin.unix/p4 $bin/bin
95 cp -r bin.unix/p4api-*/include $dev
96 cp -r bin.unix/p4api-*/lib $out
100 passthru.tests.version = testers.testVersion {
101 package = finalAttrs.finalPackage;
106 description = "Perforce Helix Core command-line client and APIs";
107 homepage = "https://www.perforce.com";
108 license = licenses.bsd2;
110 platforms = platforms.unix;
111 maintainers = with maintainers; [ corngood impl ];