Vulkan/package.nix
Alexandre 4e92afd550
All checks were successful
Build VulkanEngine / build (push) Successful in 4m41s
re added the vk loader.
i'm tired, i'll tackle it down tomorrow
2026-10-01 00:26:37 +02:00

111 lines
2.5 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, fetchgit
, cmake
, ninja
, pkg-config
, glfw3
, glm
, vulkan-headers
, vulkan-loader
, vulkan-utility-libraries
, vulkan-memory-allocator
, vk-bootstrap
, fmt
, cli11
, glslang
, shader-slang
, simdjson
}:
let
fs = lib.fileset;
fastgltf = fetchFromGitHub {
owner = "spnda";
repo = "fastgltf";
rev = "v0.8.0";
hash = "sha256-nPkVMrve1+04XRpSswBqjlSurliCFBRxR8Zxy4xZ5pE=";
};
imgui = fetchgit {
url = "https://git.alexdelcamp.fr/Alexandre_1a/imgui.git";
rev = "d7cce3ad5070bbdbbd7a39335c0c1e90071211d0";
hash = "sha256-2v085YFc17aj96YlOc4Fp8sJUHUmjRU8X54FnuqKrgc=";
};
in
stdenv.mkDerivation {
pname = "vulkan-engine";
version = "1.1.0";
src = ./.;
postUnpack = ''
# include/ peut ne pas exister du tout dans la copie flake
# (cas de figure ici), donc on le crée.
mkdir -p $sourceRoot/include
# On remplace les dossiers vides (ou absents) par les vraies sources
rm -rf $sourceRoot/include/imgui $sourceRoot/include/CLI11
cp -r ${imgui} $sourceRoot/include/imgui
# Autorise le write sur l'arbre : CMake va générer des fichiers
chmod -R u+w $sourceRoot
'';
nativeBuildInputs = [
cmake
ninja
pkg-config
glslang
shader-slang
];
buildInputs = [
glfw3
glm
vulkan-headers
vulkan-loader
vulkan-utility-libraries
vk-bootstrap
vulkan-memory-allocator
fmt
cli11
simdjson
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
"-DFETCHCONTENT_SOURCE_DIR_FASTGLTF=${fastgltf}"
"-DFETCHCONTENT_FULLY_DISCONNECTED=ON"
];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp engine/engine $out/bin/engine
cp server/server $out/bin/server
# Copier les shaders compilés où qu'ils soient
if [ -d engine/shaders ]; then
cp -r engine/shaders $out/bin/shaders
elif [ -d $sourceRoot/engine/shaders ]; then
# fallback : sources, à compiler ? normalement non
cp -r $sourceRoot/engine/shaders $out/bin/shaders
else
echo "ERREUR : aucun dossier shaders trouvé" >&2
find . -name "*.spv" >&2
exit 1
fi
[ -d engine/models ] && cp -r engine/models $out/bin/models
[ -d engine/textures ] && cp -r engine/textures $out/bin/textures
[ -f engine/LICENSE ] && cp engine/LICENSE $out/bin/LICENSE
runHook postInstall
'';
meta.mainProgram = "engine";
}