Addition of Nix flake development shell (#4184)

* Initial devshell creation.

* cmake has a check for clang and therefore override the stdenv.

* Packages from old shell were renamed.

* fixed xcb-util, added libglvnd

* Added sdl3 dependencies provided by the website given on cmake configuration.

* Lock file.

* Nix format.

* Added instructions for entering nix development shell.

.

* Added libuuid

* Added copyright text to flake.nix

* Added flake.lock to REUSE.toml as is a JSON file without comment support.

* Updated instructions to refer to new build name.

* Compiling however not yet correctly linking with debug derivation.

* Hitting installPhase

* Added nix result symlink.

* correctly installs in place

* Added a wrapper to load vulkan and ligl into environment.

* Ensure that the name is applicable to the current project.

.

* Added mesa to LD_LIBRARY_PATH

* game now launching with added X11 libraries.

* Cleanup

Formatting.

Pulled cmakeFlags to top and added releaseWithDebugInfo

Removed LD_LIBRARY_PATH from devshell.

.

* Added options for the different Nix build modes.

* Debug / release mode flag cannot be bundled into one.
This commit is contained in:
Connor Garey 2026-03-30 21:35:57 +01:00 committed by GitHub
parent a87abee8e3
commit 969955b8a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 209 additions and 1 deletions

3
.gitignore vendored
View File

@ -418,3 +418,6 @@ FodyWeavers.xsd
# JetBrains
.idea
cmake-build-*
# Nix Result symlink
result

View File

@ -22,6 +22,7 @@ path = [
"documents/Screenshots/Linux/*",
"documents/Screenshots/Windows/*",
"externals/MoltenVK/MoltenVK_icd.json",
"flake.lock",
"scripts/ps4_names.txt",
"src/images/bronze.png",
"src/images/gold.png",
@ -130,4 +131,4 @@ SPDX-License-Identifier = "MIT"
[[annotations]]
path = "src/video_core/host_shaders/fsr/*"
SPDX-FileCopyrightText = "Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved."
SPDX-License-Identifier = "MIT"
SPDX-License-Identifier = "MIT"

View File

@ -53,6 +53,23 @@ sudo zypper install clang git cmake libasound2 libpulse-devel \
nix-shell shell.nix
```
#### Nix Flake Development Shell
```bash
nix develop
cmake -S . -B build/ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ln -s ./build/compile_commands.json .
```
#### Nix Flake Build
```bash
nix build .?submodules=1#linux.debug
```
```bash
nix build .?submodules=1#linux.release
```
```bash
nix build .?submodules=1#linux.releaseWithDebugInfo
```
#### Other Linux distributions
You can try one of two methods:

27
flake.lock generated Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1774386573,
"narHash": "sha256-4hAV26quOxdC6iyG7kYaZcM3VOskcPUrdCQd/nx8obc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "46db2e09e1d3f113a13c0d7b81e2f221c63b8ce9",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

160
flake.nix Normal file
View File

@ -0,0 +1,160 @@
## SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
## SPDX-License-Identifier: GPL-2.0-or-later
{
description = "shadPS4 Nix Flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs =
{ self, nixpkgs }:
let
pkgsLinux = nixpkgs.legacyPackages.x86_64-linux;
in
{
devShells.x86_64-linux.default = pkgsLinux.mkShell.override { stdenv = pkgsLinux.clangStdenv; } {
packages = with pkgsLinux; [
clang-tools
cmake
pkg-config
vulkan-tools
renderdoc
gef
strace
openal
zlib.dev
libedit.dev
vulkan-headers
vulkan-utility-libraries
ffmpeg.dev
fmt.dev
glslang.dev
wayland.dev
stb
libpng.dev
libuuid
sdl3.dev
alsa-lib
hidapi
ibus.dev
jack2.dev
libdecor.dev
libthai.dev
fribidi.dev
libxcb.dev
libGL.dev
libpulseaudio.dev
libusb1.dev
libx11.dev
libxcursor.dev
libxext
libxfixes.dev
libxi.dev
libxinerama.dev
libxkbcommon
libxrandr.dev
libxrender.dev
libxtst
pipewire.dev
libxscrnsaver
sndio
];
shellHook = ''
echo "Entering shadPS4 development shell!"
'';
};
linux =
let
execName = "shadps4";
nativeInputs = with pkgsLinux; [
cmake
ninja
pkg-config
magic-enum
fmt
eudev
];
buildInputs = with pkgsLinux; [
boost
cli11
openal
nlohmann_json
vulkan-loader
vulkan-headers
vulkan-memory-allocator
toml11
zlib
zydis
pugixml
ffmpeg
libpulseaudio
pipewire
vulkan-loader
wayland
wayland-scanner
libX11
libxrandr
libxext
libxcursor
libxi
libxscrnsaver
libxtst
libxcb
libdecor
libxkbcommon
libGL
libuuid
];
defaultFlags = [
"-DCMAKE_INSTALL_PREFIX=$out"
];
in
{
debug = pkgsLinux.stdenv.mkDerivation {
pname = "${execName}";
version = "git";
system = "x86_64-linux";
src = ./.;
dontStrip = true;
nativeBuildInputs = nativeInputs;
buildInputs = buildInputs;
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Debug"
] ++ [defaultFlags];
};
release = pkgsLinux.stdenv.mkDerivation {
pname = "${execName}";
version = "git";
system = "x86_64-linux";
src = ./.;
nativeBuildInputs = nativeInputs;
buildInputs = buildInputs;
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
] ++ [defaultFlags];
};
releaseWithDebugInfo = pkgsLinux.stdenv.mkDerivation {
pname = "${execName}";
version = "git";
system = "x86_64-linux";
src = ./.;
dontStrip = true;
nativeBuildInputs = nativeInputs;
buildInputs = buildInputs;
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
] ++ [defaultFlags];
};
};
};
}