From 2576bb2c1831aa22f7dfaf8c5ca3aed5e1619995 Mon Sep 17 00:00:00 2001 From: Noah Fontes Date: Tue, 6 Sep 2022 23:50:31 -0700 Subject: [PATCH 1/2] p4: 2021.2.2201121 -> 2022.1.2305383, build from source The actual p4 command is open-source software released under the 2-clause BSD license, so we can build it here (for pretty much every architecture we support!) and include it in the cache. This change removes the server-side commands from this package, but they are now available as part of a separate p4d package instead. (The server package remains unfree.) As an added bonus, we can also include the libraries and headers for the C/C++ API, which will allow us to package any software that uses Perforce as a library in the future. --- .../from_md/release-notes/rl-2211.section.xml | 10 ++ .../manual/release-notes/rl-2211.section.md | 2 + .../version-management/p4/default.nix | 116 +++++++++++++++--- pkgs/top-level/all-packages.nix | 5 +- 4 files changed, 116 insertions(+), 17 deletions(-) diff --git a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml index 78bd6c6a22d8..3ae5032c0717 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml @@ -481,6 +481,16 @@ instead. + + + The p4 package now only includes the + open-source Perforce Helix Core command-line client and APIs. + It no longer installs the unfree Helix Core Server binaries + p4d, p4broker, and + p4p. To install the Helix Core Server + binaries, use the p4d package instead. + + The coq package and versioned variants diff --git a/nixos/doc/manual/release-notes/rl-2211.section.md b/nixos/doc/manual/release-notes/rl-2211.section.md index 37b0db8a8ce1..221c50b134b3 100644 --- a/nixos/doc/manual/release-notes/rl-2211.section.md +++ b/nixos/doc/manual/release-notes/rl-2211.section.md @@ -160,6 +160,8 @@ Available as [services.patroni](options.html#opt-services.patroni.enable). - `services.hbase` has been renamed to `services.hbase-standalone`. For production HBase clusters, use `services.hadoop.hbase` instead. +- The `p4` package now only includes the open-source Perforce Helix Core command-line client and APIs. It no longer installs the unfree Helix Core Server binaries `p4d`, `p4broker`, and `p4p`. To install the Helix Core Server binaries, use the `p4d` package instead. + - The `coq` package and versioned variants starting at `coq_8_14` no longer include CoqIDE, which is now available through `coqPackages.coqide`. It is still possible to get CoqIDE as part of diff --git a/pkgs/applications/version-management/p4/default.nix b/pkgs/applications/version-management/p4/default.nix index 4f61be6669aa..8a54d4eb77bf 100644 --- a/pkgs/applications/version-management/p4/default.nix +++ b/pkgs/applications/version-management/p4/default.nix @@ -1,31 +1,115 @@ -{ stdenv, fetchurl, lib, autoPatchelfHook }: +{ stdenv +, fetchurl +, fetchzip +, lib +, emptyDirectory +, linkFarm +, symlinkJoin +, jam +, libcxx +, libcxxabi +, openssl +, xcbuild +, CoreServices +, Foundation +, Security +}: +let + opensslStatic = openssl.override { + static = true; + }; + androidZlibContrib = + let + src = fetchzip { + url = "https://android.googlesource.com/platform/external/zlib/+archive/61174f4fd262c6075f88768465f308aae95a2f04.tar.gz"; + sha256 = "sha256-EMzKAHcEWOUugcHKH2Fj3ZaIHC9UlgO4ULKe3RvgxvI="; + stripRoot = false; + }; + in + linkFarm "android-zlib-contrib" [ + # We only want to keep the contrib directory as the other files conflict + # with p4's own zlib files. (For the same reason, we can't use the + # cone-based Git sparse checkout, either.) + { name = "contrib"; path = "${src}/contrib"; } + ]; + libcxxUnified = symlinkJoin { + inherit (libcxx) name; + paths = [ libcxx libcxxabi ]; + }; +in stdenv.mkDerivation rec { pname = "p4"; - version = "2021.2.2201121"; + version = "2022.1.2305383"; src = fetchurl { - # actually https://cdist2.perforce.com/perforce/r21.2/bin.linux26x86_64/helix-core-server.tgz but upstream deletes releases - url = "https://web.archive.org/web/20211118024943/https://cdist2.perforce.com/perforce/r21.2/bin.linux26x86_64/helix-core-server.tgz"; - sha256 = "sha256-SrfI2ZD7KDyttCd8+fo8g4UZKljYYO/SbzqrS9tAcC8="; + # Upstream replaces minor versions, so use archived URL. + url = "https://web.archive.org/web/20220901184735id_/https://ftp.perforce.com/perforce/r22.1/bin.tools/p4source.tgz"; + sha256 = "27ab3ddd7b178b05cf0b710e941650dac0688d294110ebafda9027732c0944c6"; }; - sourceRoot = "."; + nativeBuildInputs = [ jam ]; - dontBuild = true; + buildInputs = lib.optionals stdenv.isDarwin [ CoreServices Foundation Security ]; - nativeBuildInputs = [ autoPatchelfHook ]; + outputs = [ "out" "bin" "dev" ]; - installPhase = '' - install -D --target $out/bin p4 p4broker p4d p4p + hardeningDisable = lib.optionals stdenv.isDarwin [ "strictoverflow" ]; + + jamFlags = + [ + "-sEXEC=bin.unix" + "-sCROSS_COMPILE=${stdenv.cc.targetPrefix}" + "-sMALLOC_OVERRIDE=no" + "-sSSLINCDIR=${lib.getDev opensslStatic}/include" + "-sSSLLIBDIR=${lib.getLib opensslStatic}/lib" + ] + ++ lib.optionals stdenv.cc.isClang [ "-sOSCOMP=clang" "-sCLANGVER=${stdenv.cc.cc.version}" ] + ++ lib.optionals stdenv.cc.isGNU [ "-sOSCOMP=gcc" "-sGCCVER=${stdenv.cc.cc.version}" ] + ++ lib.optionals stdenv.isLinux [ "-sOSVER=26" ] + ++ lib.optionals stdenv.isDarwin [ + "-sOSVER=1013" + "-sMACOSX_SDK=${emptyDirectory}" + "-sLIBC++DIR=${libcxxUnified}/lib" + ]; + + CCFLAGS = + # The file contrib/optimizations/slide_hash_neon.h is missing from the + # upstream distribution. It comes from the Android/Chromium sources. + lib.optionals stdenv.isAarch64 [ "-I${androidZlibContrib}" ]; + + "C++FLAGS" = + # Avoid a compilation error that only occurs for 4-byte longs. + lib.optionals stdenv.isi686 [ "-Wno-narrowing" ] + # See the "Header dependency changes" section of + # https://www.gnu.org/software/gcc/gcc-11/porting_to.html for more + # information on why we need to include these. + ++ lib.optionals + (stdenv.cc.isClang || (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.cc.version "11.0.0")) + [ "-include" "limits" "-include" "thread" ]; + + buildPhase = '' + runHook preBuild + jam $jamFlags -j$NIX_BUILD_CORES p4 + jam $jamFlags -j$NIX_BUILD_CORES -sPRODUCTION=yes p4api.tar + runHook postBuild ''; - meta = { - description = "Perforce Command-Line Client"; + installPhase = '' + runHook preInstall + mkdir -p $bin/bin $dev $out + cp bin.unix/p4 $bin/bin + cp -r bin.unix/p4api-${version}/include $dev + cp -r bin.unix/p4api-${version}/lib $out + runHook postInstall + ''; + + meta = with lib; { + description = "Perforce Helix Core command-line client and APIs"; homepage = "https://www.perforce.com"; - sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; - license = lib.licenses.unfree; - platforms = [ "x86_64-linux" ]; - maintainers = with lib.maintainers; [ corngood ]; + license = licenses.bsd2; + mainProgram = "p4"; + platforms = platforms.unix; + maintainers = with maintainers; [ corngood impl ]; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 33ca400bbb81..5cc779182e7c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -30205,7 +30205,10 @@ with pkgs; ostinato = libsForQt5.callPackage ../applications/networking/ostinato { }; - p4 = callPackage ../applications/version-management/p4 { }; + p4 = callPackage ../applications/version-management/p4 { + inherit (darwin.apple_sdk.frameworks) CoreServices Foundation Security; + openssl = openssl_1_1; + }; p4d = callPackage ../applications/version-management/p4d { }; p4v = libsForQt515.callPackage ../applications/version-management/p4v { }; From 453192aa4ba3c76e3071531132417d45cf214485 Mon Sep 17 00:00:00 2001 From: Noah Fontes Date: Wed, 7 Sep 2022 22:33:26 -0700 Subject: [PATCH 2/2] p4d: add corngood to maintainers --- pkgs/applications/version-management/p4d/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/version-management/p4d/default.nix b/pkgs/applications/version-management/p4d/default.nix index 5b98131303d3..e2cf8e1013c3 100644 --- a/pkgs/applications/version-management/p4d/default.nix +++ b/pkgs/applications/version-management/p4d/default.nix @@ -47,6 +47,6 @@ stdenv.mkDerivation { license = licenses.unfree; mainProgram = "p4d"; platforms = builtins.attrNames srcs; - maintainers = with maintainers; [ impl ]; + maintainers = with maintainers; [ corngood impl ]; }; }