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

pcsx2: darwin support, add maintainer #320122

Merged
merged 1 commit into from
Jul 2, 2024
Merged

Conversation

matteo-pacini
Copy link
Contributor

@matteo-pacini matteo-pacini commented Jun 15, 2024

Description of changes

  • Split the package in linux.nix and darwin.nix
  • darwin.nix fetches the pre-compiled binaries from GitHub
    • Tried to compile this but fails on aarch64-darwin, requires a x86_64-darwin machine
    • Cannot be compiled also as Xcode is needed to build Metal shaders
    • The pre-compiled app runs fine under Rosetta, the version is in sync with the Linux one
  • The three files have been formatted with nixfmt-rfc-style.
  • Added myself as maintainer for Darwin

Screenshot 2024-06-15 at 20 09 40

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Jun 15, 2024
@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jun 15, 2024
@matteo-pacini matteo-pacini force-pushed the pcsx2 branch 2 times, most recently from 0e0c51d to 02800cf Compare June 16, 2024 22:16
@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-ready-for-review/3032/4127

@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-ready-for-review/3032/4132

@afh
Copy link
Member

afh commented Jun 23, 2024

Result of nixpkgs-review pr 320122 run on aarch64-darwin 1

1 package built:
  • pcsx2

Copy link
Member

@afh afh left a comment

Choose a reason for hiding this comment

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

Nicely done, @matteo-pacini, please find below some hopefully helpful comments for potential future improvement…

Copy link
Member

Choose a reason for hiding this comment

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

❓ What are your thoughts around adding support to build this package on x86_64-darwin instead of installing the pre-built binary from upstream?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@afh Imho, It would make this package harder to maintain - I would make it compile from source only if it's supported on both aarch64-darwin and x86_64-darwin.

I also expect x86_64-darwin to slowly lose traction and disappear, so any effort towards that architecture could potentially become a waste of maintainers' time.

This is just my personal opinion, and up to debate: I expect plenty of new Nix adopter to be on aarch64-darwin, rather than x86_64-darwin.

Copy link
Member

Choose a reason for hiding this comment

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

It might be worth reconsidering this in light of the upcoming Apple Silicon support?

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense, @matteo-pacini, I'm alright with this being x86_64-darwin until Apple Silicon supports lands upstream and this can be built from source.

pkgs/by-name/pc/pcsx2/package.nix Show resolved Hide resolved
@afh
Copy link
Member

afh commented Jun 23, 2024

The app requires Rosetta to run, how could this dependency be declared in nixpkgs in general to differentiate between packages that run natively on Apple Silicon and packages needing Rosetta?

@matteo-pacini
Copy link
Contributor Author

matteo-pacini commented Jun 23, 2024

@afh That's a good point - my gut tells me this should only be declared as a x86_64-darwin derivation, and then aarch64-darwin can download this anyway by using Nix config / extra platforms.

@NixOS/darwin-maintainers thoughts on this?

@SuperSamus
Copy link
Contributor

FYI, upstream is working on natively supporting ARM.
https://github.com/PCSX2/pcsx2/pull/11364

@emilazy
Copy link
Member

emilazy commented Jun 23, 2024

That's a good point - my gut tells me this should only be declared as a x86_64-darwin derivation, and then aarch64-darwin can download this anyway by using Nix config / extra platforms.

I agree. There’s nothing about this app that is aarch64-darwin (currently); it just so happens that all aarch64-darwin machines support software that lets them run x86_64-darwin software.

@matteo-pacini
Copy link
Contributor Author

@SuperSamus @afh @emilazy Thanks for the feedback, I'm going to change the derivation and make it natively compile for x86_64-darwin, so it's ready for when aarch64-darwin support will be officially released.

Copy link
Member

@afh afh left a comment

Choose a reason for hiding this comment

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

Thanks everyone for chiming in on this, very helpful 🙏

@matteo-pacini please find below updated comments 🙂

pkgs/by-name/pc/pcsx2/package.nix Show resolved Hide resolved
mainProgram = "pcsx2-qt";
platforms = [ "x86_64-linux" ];
platforms = [ "x86_64-linux" ] ++ platforms.darwin;
Copy link
Member

Choose a reason for hiding this comment

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

Given the latest comments as this PR stands now I kindly request the following change:

Suggested change
platforms = [ "x86_64-linux" ] ++ platforms.darwin;
platforms = [ "x86_64-linux" "x86_64-darwin" ];

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense, @matteo-pacini, I'm alright with this being x86_64-darwin until Apple Silicon supports lands upstream and this can be built from source.

@matteo-pacini matteo-pacini changed the title pcsx2: darwin app, add maintainer pcsx2: darwin support, add maintainer Jun 23, 2024
@matteo-pacini matteo-pacini marked this pull request as draft June 23, 2024 17:23
@matteo-pacini matteo-pacini force-pushed the pcsx2 branch 3 times, most recently from 58a3994 to 456b2ff Compare June 23, 2024 19:32
@ofborg ofborg bot added 10.rebuild-linux: 1-10 10.rebuild-linux: 1 and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jun 23, 2024
@matteo-pacini matteo-pacini force-pushed the pcsx2 branch 4 times, most recently from 1f8faa2 to bb341a1 Compare June 23, 2024 21:12
@matteo-pacini
Copy link
Contributor Author

matteo-pacini commented Jun 24, 2024

@emilazy I've encountered a roadblock, the build fails when trying to compile Metal shaders, as that would require host's tools, Xcode and xcrun.

What's the best / ideal way forward here? Here's four potential approaches:

  1. Expose hosts tool. Using tools on the host would be tricky, i.e. it will depend on the host having Xcode installed - lot of impurity.
  2. Patching the app so the shaders are not compiled, just copied over, but then I would have to change the Metal pipeline, so those are compiled at runtime instead. Not impossible but this would be highly time consuming. Also we don't know for how long this will work and might require constant maintenance over time.
  3. Fetch the binary dist from Github regardless, and copy over the pre-compiled *.metallib files to the final app bundle - not ideal, but it should work.
  4. We could just stick to the binary distribution as a temporary solution, and think how to bring Metal shader compiling into the packaging pipeline, so other derivations can benefit from it too, and revisit this at a later stage.

Pinging also @NixOS/darwin-maintainers, any advice would be greatly appreciated.

@matteo-pacini matteo-pacini force-pushed the pcsx2 branch 2 times, most recently from 701aa6f to 02800cf Compare June 25, 2024 06:44
@matteo-pacini matteo-pacini marked this pull request as ready for review June 25, 2024 06:48
@matteo-pacini
Copy link
Contributor Author

matteo-pacini commented Jun 25, 2024

@emilazy @afh reverted this PR to its previous state.

As stated in #320122 (comment), some thinking is required to bring Metal shaders into the pipeline.
I don't thinks there's an immediate / obvious solution to this, so I suggest to go with option (4) from the previous comment, rather than having no Darwin support at all.

I'll bring this topic up on Matrix when I got some time 👍🏻

@ofborg ofborg bot added 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux and removed 10.rebuild-linux: 1 10.rebuild-linux: 1-10 labels Jun 25, 2024
@matteo-pacini matteo-pacini force-pushed the pcsx2 branch 2 times, most recently from 0b6e931 to b49a0d5 Compare June 25, 2024 07:40
@matteo-pacini matteo-pacini requested review from afh and emilazy June 25, 2024 07:40
Copy link
Member

@afh afh left a comment

Choose a reason for hiding this comment

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

I agree with you, @matteo-pacini.

Would you be interested in setting up a draft PR for the native darwin build that also tracks the development of Apple silicon in upstream? Might be helpful to get folks together and advise on best paths forward in regards to xcrun and Xcode…

@matteo-pacini matteo-pacini added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Jun 25, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin and removed 10.rebuild-darwin: 1 10.rebuild-darwin: 1-10 labels Jul 1, 2024
@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Jul 1, 2024
Copy link
Member

@afh afh left a comment

Choose a reason for hiding this comment

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

🙂👍

Copy link
Contributor

@toonn toonn left a comment

Choose a reason for hiding this comment

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

LGTM

@toonn toonn merged commit ae472bb into NixOS:master Jul 2, 2024
27 checks passed
@Sigmanificient Sigmanificient added the 0.kind: package adoption Requests or PRs for adopting packages that have no maintainers label Jul 14, 2024
@matteo-pacini matteo-pacini mentioned this pull request Aug 12, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: package adoption Requests or PRs for adopting packages that have no maintainers 6.topic: darwin Running or building packages on Darwin 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants