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

Add nix-shell to allow native build on NixOS #2333

Merged
merged 5 commits into from
Feb 7, 2025

Conversation

shokerplz
Copy link
Contributor

This PR adds nix-shell that will allow to build shadPS4 on nixos natively. While we can use distrobox, native approach is much better since it allows us to run it on nix-machines without the need to install docker and it allows to reproduce builds without worrying about different versions of dependencies.

Tested on x86_64

@tomboylover93
Copy link
Contributor

I feel like shell.nix should be at the root of the filesystem instead of in documents/build-nixos. That, and the README.md in that folder should be moved to to documents/ and renamed to building-nix.md

@shokerplz
Copy link
Contributor Author

I think you're right about moving shell.nix to root, initially I though it was not a great idea to add files to root that's all.
Regarding readme I moved the main info to comment inside shell.nix, this way anyone who wants to know why custom vulkan packages are used can read it there.

@aatmunbaxi
Copy link

I can't seem to initialize this shell, it returns a 404 error when attempting to fetch the Vulkan-Utility-Libraries-1.4.305 tarball.

trying https://github.com/KhronosGroup/Vulkan-Utility-Libraries/archive/vulkan-sdk-1.4.305.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
error: cannot download source from any mirror

Output of nix-info -m --host-os --sandbox:

  • system: "x86_64-linux"
  • host os: Linux 6.6.72, NixOS, 24.11 (Vicuna), 24.11.20250118.6a3ae7a
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.24.11
  • channels(root): "home-manager-24.11.tar.gz, nixos-24.11"
  • nixpkgs: /nix/store/n67nldl8x3f44w9mvk5zvij0q1rwnsmq-source

@shokerplz
Copy link
Contributor Author

shokerplz commented Feb 2, 2025

@aatmunbaxi that's because sdk version is 1.4.304.0 (and nixpkgs repo uses sdk version https://github.com/nixos/nixpkgs/blob/master/pkgs/development/libraries/vulkan-headers/default.nix#L26) , 1.4.305 is not the one (https://github.com/KhronosGroup/Vulkan-Tools?tab=readme-ov-file#version-tagging-scheme). This project requires 1.4.305 (https://github.com/shadps4-emu/shadPS4/blob/main/CMakeLists.txt#L153) so it makes sense to grab this one, but 1.4.304.0 would also work (I have tested it).
In any case, once NixOS/nixpkgs#373969 will reach unstable branch, it would be possible to use sdk version without rebuilding everything.

@tomboylover93
Copy link
Contributor

Question, how often does the NixOS unstable branch get updated? That PR already got merged so it should be possible to use 1.4.304 without building it from source, no?

@shokerplz
Copy link
Contributor Author

That's the unknown part unfortunately, all I know is that unstable channel get's updated when somebody with commit access pushes changes to master. The PR I've mentioned got merged to stagging branch and not to master, because of high amount of dependencies. So according to me and to https://nixos.wiki/wiki/Nix_channels we have no answer to this question.
And that was the motivation I had when I started working on this nix shell.
We ofc can wait till vulkan stuff will be updated, I already have a nix-shell ready for that, but until then we can only use custom pkgs.

@tomboylover93
Copy link
Contributor

I think it would be better to wait until that happens to use the packages available in NixOS staging instead of building the Vulkan utility libraries from source, it saves us more time and avoids issues like the error 404 one mentioned above (I'm having the same issue).

@ryand56
Copy link

ryand56 commented Feb 3, 2025

That's the unknown part unfortunately, all I know is that unstable channel get's updated when somebody with commit access pushes changes to master. The PR I've mentioned got merged to stagging branch and not to master, because of high amount of dependencies. So according to me and to nixos.wiki/wiki/Nix_channels we have no answer to this question. And that was the motivation I had when I started working on this nix shell. We ofc can wait till vulkan stuff will be updated, I already have a nix-shell ready for that, but until then we can only use custom pkgs.

NixOS maintainer here. Staging updates AFAIK go into staging-next, and then merged into the master branch. The current staging-next PR is NixOS/nixpkgs#377253

@shokerplz
Copy link
Contributor Author

Ookay, that's actually helpful, in that case in the next two weeks we would probably get new vulkan packages which would solve the problem. Alrighty let's wait until then.

@tomboylover93
Copy link
Contributor

You should probably turn this PR into a draft in the meantime.

@shokerplz shokerplz marked this pull request as draft February 3, 2025 15:59
@squidbus
Copy link
Collaborator

squidbus commented Feb 4, 2025

Only concern here is that I don't think a lot of frequent contributors are Nix users so the build file could drift as changes are made. So I guess if you're okay with that and can keep it maintained it might be fine.

@shokerplz
Copy link
Contributor Author

Sure that's the plan and the possible changes shouldn't be very complex, if I was able to build a working shell - I am pretty sure there're bunch of people in the community who can do it even better.
I also believe once people are gonna be able to build it on nix without trying to find out how vulkan stuff should be built - the amount of those users will increase.
As a side note I've found only one nix package with shadPS4 and it's not in official repo and also only 0.4.0, so I want to make a proper package as well, but that's out of the scope of this PR even tho a proper shell would be handy for the future.

@shokerplz shokerplz marked this pull request as ready for review February 7, 2025 15:48
@shokerplz
Copy link
Contributor Author

Ookay, so the PR in nixpkgs got merged and I have changed shell.nix to use official unstable channel, so this PR is ready to be merged

@georgemoralis
Copy link
Collaborator

it fails the reuse , you need to exclude it in reuse.toml file

@shokerplz
Copy link
Contributor Author

I've added a license header to shell.nix since it supports comments, so no need to exclude it

@georgemoralis georgemoralis merged commit cb14431 into shadps4-emu:main Feb 7, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants