Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p4: 2021.2.2201121 -> 2022.1.2305383, build from source and remove unfree binaries #190105

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

impl
Copy link
Member

@impl impl commented Sep 7, 2022

Description of changes

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 (#190100) instead. (The server package remains unfree, and to make users' lives easier its PR should probably be merged before this one.)

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.

Please note that I am employed by Perforce but I am not currently supporting these packages in an official capacity.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

CCFLAGS =
# Appears to be missing from upstream distribution, but is in fact
# open-source redistributable software.
lib.optionals stdenv.isAarch64 [ "-I${./aarch64/zlib/include}" ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we pull this from somewhere instead of keeping it in nixpkgs?

Copy link
Contributor

@corngood corngood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@AndersonTorres
Copy link
Member

It means that it is possible to catch jam directly from the original repo using this P4?

@impl
Copy link
Member Author

impl commented Sep 11, 2022

Hmm, I suppose in theory you could implement a fetchp4 fetcher and use it to acquire Jam, but it would introduce a dependency cycle like fetchurl<->curl (i.e., it would need a bootstrapping phase of some sort anyway) because p4 needs Jam to build itself, right?

@AndersonTorres
Copy link
Member

Well, that was unexpected.
I was talking about p4->git clone Jam to a Github repository, as a form of backup.

@impl
Copy link
Member Author

impl commented Sep 12, 2022

Oh! Ha. Sorry for the misunderstanding! Yes, that's certainly possible, and there's actually even a git p4 command that can bridge the two.

Edit: If you have the p4 command installed, then you can do:

$ P4PORT=public.perforce.com:1666 P4USER=guest git p4 clone //guest/perforce_software/jam/src/...@all --destination jam

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/631

++ lib.optionals stdenv.isLinux [ "-sOSVER=26" ]
++ lib.optionals stdenv.isDarwin [ "-sOSVER=1013" ];

outputs = [ "bin" "dev" "out" ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
outputs = [ "bin" "dev" "out" ];
outputs = [ "out" "bin" "dev" ];

otherwise leftover files end up in bin

Comment on lines 56 to 74
CROSS_COMPILE = stdenv.cc.targetPrefix;
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" ];
MALLOC_OVERRIDE = "no";
SSLINCDIR = "${lib.getDev opensslStatic}/include";
SSLLIBDIR = "${lib.getLib opensslStatic}/lib";
MACOSX_SDK = lib.optionalString stdenv.isDarwin "${emptyDirectory}";
"LIBC++DIR" = lib.optionalString stdenv.isDarwin "${libcxxUnified}/lib";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those should be exportet in some prePhase like preBuild

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all actually flags to jam, so I'm just going to move them into there. The way I have them split out right now doesn't really make any sense I don't think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved all of them except CCFLAGS and C++FLAGS which are Jam's standard equivalent to the autotools/make convention of CFLAGS and CXXFLAGS, respectively, so they felt like they could stay at the top level. Since they're built from a list of conditionals it's also harder to put them inside a preBuild-style script that maintains readability.

Comment on lines 50 to 51
buildInputs = lib.optionals stdenv.isDarwin [ CoreServices Foundation Security ];
nativeBuildInputs = [ jam ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
buildInputs = lib.optionals stdenv.isDarwin [ CoreServices Foundation Security ];
nativeBuildInputs = [ jam ];
nativeBuildInputs = [ jam ];
buildInputs = lib.optionals stdenv.isDarwin [ CoreServices Foundation Security ];

# 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 cached URL.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Upstream replaces minor versions, so use cached URL.
# Upstream replaces minor versions, so use cached URL.
Suggested change
# Upstream replaces minor versions, so use cached URL.
# Upstream replaces minor versions, so use archived URL.

paths = [ libcxx libcxxabi ];
};

version = "2022.1.2305383";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that moved here? It is unused.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used further down to determine the path of the p4api directory, so I can call mkDerivation without using rec. If using rec is OK with you I can of course just put it directly in there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using rec is totally fine.

@impl impl force-pushed the free-p4 branch 2 times, most recently from 97064c5 to 8a56bcb Compare October 8, 2022 06:23
@ofborg ofborg bot requested a review from corngood October 8, 2022 06:34
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.
@impl
Copy link
Member Author

impl commented Oct 9, 2022

@SuperSandro2000 Thank you for the detailed review! I think I addressed everything, but please let me know if there are any other changes you'd like to see.

@AndersonTorres AndersonTorres merged commit 77c986e into NixOS:master Oct 11, 2022
@impl impl deleted the free-p4 branch October 11, 2022 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants