From 969955b8a086b79dc107eabbb663ed9cf1308e60 Mon Sep 17 00:00:00 2001 From: Connor Garey Date: Mon, 30 Mar 2026 21:35:57 +0100 Subject: [PATCH] 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. --- .gitignore | 3 + REUSE.toml | 3 +- documents/building-linux.md | 17 ++++ flake.lock | 27 ++++++ flake.nix | 160 ++++++++++++++++++++++++++++++++++++ 5 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 683f6f0a6..7ace5e4f6 100644 --- a/.gitignore +++ b/.gitignore @@ -418,3 +418,6 @@ FodyWeavers.xsd # JetBrains .idea cmake-build-* + +# Nix Result symlink +result diff --git a/REUSE.toml b/REUSE.toml index 22bed2a50..e8997f007 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -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" \ No newline at end of file +SPDX-License-Identifier = "MIT" diff --git a/documents/building-linux.md b/documents/building-linux.md index 49aacdfc9..9495a226b 100644 --- a/documents/building-linux.md +++ b/documents/building-linux.md @@ -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: diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..246cfd4e7 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..9042105c5 --- /dev/null +++ b/flake.nix @@ -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]; + }; + }; + }; +}