Skip to content

Commit

Permalink
Add nix-shell to allow native build on NixOS (shadps4-emu#2333)
Browse files Browse the repository at this point in the history
* Add nix-shell to allow native build on NixOS

* Remove unnecessary README for nix. Move major comment to shell.nix

* Update path in building-linux.md

* Use cached nix packages from unstable channel

* Add proper license to nix shell
  • Loading branch information
shokerplz authored Feb 7, 2025
1 parent 3c5cb09 commit cb14431
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
8 changes: 7 additions & 1 deletion documents/building-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ sudo pacman -S base-devel clang git cmake sndio jack2 openal qt6-base qt6-declar
sudo zypper install clang git cmake libasound2 libpulse-devel libsndio7 libjack-devel openal-soft-devel libopenssl-devel zlib-devel libedit-devel systemd-devel libevdev-devel qt6-base-devel qt6-multimedia-devel qt6-svg-devel qt6-linguist-devel qt6-gui-private-devel vulkan-devel vulkan-validationlayers
```

#### NixOS

```
nix-shell shell.nix
```

#### Other Linux distributions

You can try one of two methods:
Expand All @@ -49,7 +55,7 @@ distrobox create --name archlinux --init --image archlinux:latest
```

and install the dependencies on that container as cited above.
This option is **highly recommended** for NixOS and distributions with immutable/atomic filesystems (example: Fedora Kinoite, SteamOS).
This option is **highly recommended** for distributions with immutable/atomic filesystems (example: Fedora Kinoite, SteamOS).

### Cloning

Expand Down
70 changes: 70 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later

with import (fetchTarball "https://github.com/nixos/nixpkgs/archive/cfd19cdc54680956dc1816ac577abba6b58b901c.tar.gz") { };

pkgs.mkShell {
name = "shadps4-build-env";

nativeBuildInputs = [
pkgs.llvmPackages_18.clang
pkgs.cmake
pkgs.pkg-config
pkgs.git
];

buildInputs = [
pkgs.alsa-lib
pkgs.libpulseaudio
pkgs.openal
pkgs.openssl
pkgs.zlib
pkgs.libedit
pkgs.udev
pkgs.libevdev
pkgs.SDL2
pkgs.jack2
pkgs.sndio
pkgs.qt6.qtbase
pkgs.qt6.qttools
pkgs.qt6.qtmultimedia

pkgs.vulkan-headers
pkgs.vulkan-utility-libraries
pkgs.vulkan-tools

pkgs.ffmpeg
pkgs.fmt
pkgs.glslang
pkgs.libxkbcommon
pkgs.wayland
pkgs.xorg.libxcb
pkgs.xorg.xcbutil
pkgs.xorg.xcbutilkeysyms
pkgs.xorg.xcbutilwm
pkgs.sdl3
pkgs.stb
pkgs.qt6.qtwayland
pkgs.wayland-protocols
];

shellHook = ''
echo "Entering shadPS4 dev shell"
export QT_QPA_PLATFORM="wayland"
export QT_PLUGIN_PATH="${pkgs.qt6.qtwayland}/lib/qt-6/plugins:${pkgs.qt6.qtbase}/lib/qt-6/plugins"
export QML2_IMPORT_PATH="${pkgs.qt6.qtbase}/lib/qt-6/qml"
export CMAKE_PREFIX_PATH="${pkgs.vulkan-headers}:$CMAKE_PREFIX_PATH"
# OpenGL
export LD_LIBRARY_PATH="${
pkgs.lib.makeLibraryPath [
pkgs.libglvnd
pkgs.vulkan-tools
]
}:$LD_LIBRARY_PATH"
export LDFLAGS="-L${pkgs.llvmPackages_18.libcxx}/lib -lc++"
export LC_ALL="C.UTF-8"
export XAUTHORITY=${builtins.getEnv "XAUTHORITY"}
'';
}

0 comments on commit cb14431

Please sign in to comment.