Additions to Nix flake. (#4592)

Added cmake flags as optionals.

Moved X libs into its own list.

Replaced old callPackages.

Moved to let block at top level packages.

Created a function to get the correct attribute set from buildSettings.

.

Import lib

explicitly gave releaseWithDebugInfo callPackage build.

Remove lib output

Prepended pkgsLinux

Formatting.

Remove brace

.

Call the lambda first and get the output after using ()

Added buildDeps

removed fmt and eudev from native

Removed dependencies from devshell and use inputsFrom instead.

Added the inputs for the CMake modules in the derivation inputs.

Changed path and added name.

Added enableSystemLibraries flag

Removed xLibs and added flag for ENABLE_SYSTEM_LIBRARIES

Use sdl3 submodule for compiling locally.

.

.

Formatting.

Building with system libraries enabled.

Added libGL to devshell, added sdl3 and libx11 to buildInputs

Removed comment

Added devshell SDL configuration libs.

.

.

.

.

Use cmakeBool

Made buildInputs with no let in

Removed sdl3

Formatting

.

removed enableTests
This commit is contained in:
Connor Garey 2026-06-18 14:13:04 +01:00 committed by GitHub
parent 462cd0724a
commit 619e8f5292
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

270
flake.nix
View File

@ -12,6 +12,7 @@
{ self, nixpkgs }: { self, nixpkgs }:
let let
pkgsLinux = nixpkgs.legacyPackages.x86_64-linux; pkgsLinux = nixpkgs.legacyPackages.x86_64-linux;
in in
{ {
formatter.x86_64-linux = pkgsLinux.nixpkgs-fmt; formatter.x86_64-linux = pkgsLinux.nixpkgs-fmt;
@ -19,115 +20,74 @@
devShells.x86_64-linux.default = devShells.x86_64-linux.default =
let let
shell = shell =
{ mkShell { self
, mkShell
, clangStdenv , clangStdenv
, clang-tools , clang-tools
, cmake , cmake
, pkg-config , pkg-config
, vulkan-tools
, renderdoc , renderdoc
, gef , gef
, strace , strace
, perf , perf
, openal
, zlib
, libedit
, vulkan-headers
, vulkan-utility-libraries
, ffmpeg
, fmt
, glslang
, wayland
, stb
, libpng
, libuuid
, sdl3 , sdl3
, alsa-lib , vulkan-tools
, hidapi
, ibus
, jack2
, libdecor
, libthai
, fribidi
, libxcb
, libGL , libGL
, jack1
, fribidi
, libthai
, libpulseaudio , libpulseaudio
, sndio
, libdrm
, libgbm
, libusb1 , libusb1
, libx11 , libxkbcommon
, libxcursor , libxcursor
, libxext , libxext
, libxfixes , libxfixes
, libxi , libxi
, libxinerama , libxinerama
, libxkbcommon
, libxrandr , libxrandr
, libxrender , libxrender
, libxtst , libxtst
, pipewire
, libxscrnsaver , libxscrnsaver
, sndio , enableDebugTooling ? true
, cli11
, nlohmann_json
, spdlog
, freetype
, ,
}: }:
mkShell.override { stdenv = clangStdenv; } { mkShell.override { stdenv = clangStdenv; } {
packages = [ inputsFrom = [ self.packages.x86_64-linux.default ];
clang-tools
cmake
pkg-config
vulkan-tools
renderdoc packages =
gef let
strace # SDL3 requres extra libraries inside the devshell in order to pass CMake's configure.
perf sdlConfigureDeps = [
libGL
openal jack1
zlib.dev fribidi
libedit.dev libthai
vulkan-headers libpulseaudio
vulkan-utility-libraries sndio
ffmpeg.dev libdrm
fmt.dev libgbm
glslang.dev libusb1
wayland.dev libxkbcommon
stb libxcursor
libpng.dev libxext
libuuid libxfixes
cli11 libxi
nlohmann_json libxinerama
spdlog.dev libxrandr
libxrender
sdl3.dev libxtst
alsa-lib libxscrnsaver
hidapi ];
ibus.dev in
jack2.dev [
libdecor.dev clang-tools
libthai.dev cmake
fribidi.dev pkg-config
libxcb.dev ] ++ sdlConfigureDeps ++ pkgsLinux.lib.optionals enableDebugTooling [ renderdoc gef strace perf vulkan-tools ];
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
freetype.dev
];
shellHook = '' shellHook = ''
echo "Entering shadPS4 development shell!" echo "Entering shadPS4 development shell!"
@ -139,34 +99,22 @@
}; };
in in
pkgsLinux.callPackage shell { }; pkgsLinux.callPackage shell { inherit self; };
packages.x86_64-linux = packages.x86_64-linux =
let let
buildSettings = {
"release" = { symbols = false; flag = "-DCMAKE_BUILD_TYPE=Release"; };
"relWithDebInfo" = { symbols = true; flag = "-DCMAKE_BUILD_TYPE=RelWithDebInfo"; };
"debug" = { symbols = true; flag = "-DCMAKE_BUILD_TYPE=Debug"; };
};
getBuildSettings = chosenBuild: buildSettings.${chosenBuild} or (abort "Build mode not valid! Use \"debug\", \"release\", or \"relWithDebInfo\".");
build = build =
{ clangStdenv { clangStdenv
, cmake , cmake
, ninja , ninja
, pkg-config , pkg-config
, magic-enum
, fmt
, eudev
, boost
, cli11
, openal
, nlohmann_json
, vulkan-loader
, vulkan-headers
, vulkan-memory-allocator
, toml11
, zlib
, zydis
, pugixml
, ffmpeg
, libpulseaudio
, pipewire
, wayland
, wayland-scanner
, libX11 , libX11
, libxrandr , libxrandr
, libxext , libxext
@ -175,68 +123,90 @@
, libxscrnsaver , libxscrnsaver
, libxtst , libxtst
, libxcb , libxcb
, libdecor , boost
, libxkbcommon , cli11
, libGL , ffmpeg
, libuuid , fmt
, miniz
, libressl
, freetype , freetype
, cmakeFlags , glslang
, dontStrip ? true , magic-enum
, miniupnpc
, miniz
, nlohmann_json
, libpng
, openal
, libressl
, renderdoc
, sdl3
, stb
, toml11
, robin-map
, vulkan-headers
, vulkan-memory-allocator
, xbyak
, xxhash
, zlib
, zydis
, pugixml
, libuuid
, systemdMinimal
, libx11
, releaseMode ? "debug"
, enableDiscordRpc ? false
, ,
}: }:
clangStdenv.mkDerivation (finalAttrs: { clangStdenv.mkDerivation (finalAttrs: {
inherit cmakeFlags dontStrip; name = "${finalAttrs.pname}-${finalAttrs.version}-${finalAttrs.system}";
pname = "shadps4"; pname = "shadps4";
version = "0.16.1"; version = "0.16.1";
system = "x86_64-linux"; system = "x86_64-linux";
src = "${self}"; src = ./.;
nativeBuildInputs = [ nativeBuildInputs = [
cmake cmake
ninja ninja
pkg-config pkg-config
magic-enum
fmt
eudev
]; ];
buildInputs = [ buildInputs = [
boost boost
cli11 cli11
openal ffmpeg
fmt
freetype
glslang
magic-enum
miniupnpc
miniz
nlohmann_json nlohmann_json
vulkan-loader libpng
openal
libressl
renderdoc
sdl3
stb
toml11
robin-map
vulkan-headers vulkan-headers
vulkan-memory-allocator vulkan-memory-allocator
toml11 xbyak
xxhash
zlib zlib
zydis zydis
pugixml pugixml
ffmpeg
libpulseaudio
pipewire
wayland
wayland-scanner
libX11
libxrandr
libxext
libxcursor
libxi
libxscrnsaver
libxtst
libxcb
libdecor
libxkbcommon
libGL
libuuid libuuid
miniz systemdMinimal
libressl libx11
freetype
]; ];
cmakeFlags = [
(getBuildSettings releaseMode).flag
(pkgsLinux.lib.cmakeBool "ENABLE_DISCORD_RPC" enableDiscordRpc)
(pkgsLinux.lib.cmakeBool "ENABLE_TESTS" false)
(pkgsLinux.lib.cmakeBool "ENABLE_SYSTEM_LIBRARIES" true)
];
dontStrip = (getBuildSettings releaseMode).symbols;
# Cannot get the Branch name from the sandbox. # Cannot get the Branch name from the sandbox.
# Getting the commit hash can still be acquired through self. # Getting the commit hash can still be acquired through self.
patchPhase = '' patchPhase = ''
@ -247,26 +217,12 @@
--replace-fail "@GIT_DESC@" "" --replace-fail "@GIT_DESC@" ""
''; '';
}); });
debugBuild = pkgsLinux.callPackage build
{
cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Debug" ];
};
releaseBuild = pkgsLinux.callPackage build
{
dontStrip = false;
cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" ];
};
releaseWithDebugInfoBuild = pkgsLinux.callPackage build
{
cmakeFlags = [ "-DCMAKE_BUILD_TYPE=RelWithDebInfo" ];
};
in in
{ {
debug = debugBuild; debug = pkgsLinux.callPackage build { releaseMode = "debug"; };
release = releaseBuild; release = pkgsLinux.callPackage build { releaseMode = "release"; };
releaseWithDebugInfo = releaseWithDebugInfoBuild; releaseWithDebInfo = pkgsLinux.callPackage build { releaseMode = "relWithDebInfo"; };
default = releaseWithDebugInfoBuild; default = pkgsLinux.callPackage build { releaseMode = "relWithDebInfo"; };
}; };
}; };
} }