From 10cae50b342123d0ea914a1d1e5cafe7fc886f6b Mon Sep 17 00:00:00 2001 From: Fag Fag Fag Sahur Date: Wed, 16 Sep 2026 19:19:41 +0100 Subject: [PATCH] Add Nix flake and development shell (#645) --- README.md | 22 +++++++++++++ flake.lock | 27 ++++++++++++++++ flake.nix | 20 ++++++++++++ nix/devshell.nix | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ shell.nix | 4 +++ 5 files changed, 157 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/devshell.nix create mode 100644 shell.nix diff --git a/README.md b/README.md index b7ec678b..ef1cf3dd 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,28 @@ time. The CMake source root is the repository root. +### Building on NixOS + +A development shell provides Clang, CMake, Ninja, Qt 6, the Vulkan headers, and the SDL2 backend +libraries. Enter it and configure exactly as on other Linux distributions; the shell exports +`CMAKE_PREFIX_PATH` and `QT_PLUGIN_PATH`, so the `-DCMAKE_PREFIX_PATH="$Qt6_DIR"` argument is not +needed: + +```bash +nix-shell # or: nix develop +git submodule update --init --recursive + +cmake -S . -B _Build/linux -G Ninja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + +cmake --build _Build/linux --target launcher --parallel +cmake --install _Build/linux --prefix _Build/linux/install +``` + +The configure step downloads the FFmpeg prebuilts and the `xbyak`/`zydis` sources, so it needs +network access; a fully sandboxed `nix build` would require vendoring those inputs. A Vulkan 1.3 +driver must be available at runtime (on NixOS, `hardware.graphics.enable = true`). + ### Building on macOS macOS builds target x86-64 and run under Rosetta 2 on Apple Silicon, so the PS5's x86-64 game diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..ece35b8b --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1789426278, + "narHash": "sha256-GnotcvKtbTMnoVx6G4E7ZdUX6487Dky74dqq3pU7iRk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "efe6f071ede9d21c37462d2d6682d5e670099684", + "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 00000000..1a4be725 --- /dev/null +++ b/flake.nix @@ -0,0 +1,20 @@ +{ + description = "KytyPS5 development shell"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = { self, nixpkgs }: + let + systems = [ "x86_64-linux" ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + in + { + devShells = forAllSystems (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + default = import ./nix/devshell.nix { inherit pkgs; }; + }); + }; +} diff --git a/nix/devshell.nix b/nix/devshell.nix new file mode 100644 index 00000000..bdfcb653 --- /dev/null +++ b/nix/devshell.nix @@ -0,0 +1,84 @@ +{ pkgs }: + +let + # Build-time dependencies. Every -dev package the bundled SDL2 probes for must + # be listed here, otherwise SDL2 quietly drops the audio/Wayland/udev backends. + buildDeps = with pkgs; [ + qt6.qtbase # Concurrent, Network, Widgets (launcher) + vulkan-headers + vulkan-loader + vulkan-tools + vulkan-validation-layers + libglvnd + # X11 / input + libX11 + libXcursor + libXext + libXfixes + libXi + libXrandr + libXScrnSaver + libxkbcommon + # Wayland + wayland + wayland-protocols + libdecor + # audio + device/dbus + alsa-lib + libpulseaudio + systemd # libudev + dbus + ]; + + # Libraries the built binaries need at runtime. + runtimeLibs = with pkgs; [ + stdenv.cc.cc.lib # libstdc++ / libgcc_s + libgcc.lib + qt6.qtbase # libQt6Concurrent/Network/Widgets + vulkan-loader + libglvnd + alsa-lib + libpulseaudio + libX11 + libXcursor + libXext + libXfixes + libXi + libXrandr + libXScrnSaver + libxkbcommon + wayland + libdecor + systemd + dbus + ]; +in +pkgs.mkShell { + name = "kytyps5"; + + nativeBuildInputs = with pkgs; [ + clang + lld + cmake + ninja + pkg-config + git + glslang # provides glslangValidator for the bundled shaders + ]; + + buildInputs = buildDeps; + + shellHook = '' + export CMAKE_PREFIX_PATH="${pkgs.qt6.qtbase}:''${CMAKE_PREFIX_PATH:-}" + export QT_PLUGIN_PATH="${pkgs.qt6.qtbase}/lib/qt-6/plugins:${pkgs.qt6.qtbase}/lib/qt6/plugins:''${QT_PLUGIN_PATH:-}" + export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath runtimeLibs}:''${LD_LIBRARY_PATH:-}" + + if [ -z "''${KYTY_SHELL_QUIET:-}" ]; then + echo "KytyPS5 dev shell" + echo " cmake -S . -B _Build/linux -G Ninja -DCMAKE_BUILD_TYPE=Release \\" + echo " -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++" + echo " cmake --build _Build/linux --target launcher --parallel" + echo " cmake --install _Build/linux --prefix _Build/linux/install" + fi + ''; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..ebefdba6 --- /dev/null +++ b/shell.nix @@ -0,0 +1,4 @@ +let + pkgs = import { }; +in +import ./nix/devshell.nix { inherit pkgs; }