nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 847 lines 30 kB view raw
1{ 2 alsa-lib, 3 apple-sdk_26, 4 autoPatchelfHook, 5 buildPackages, 6 callPackage, 7 darwin, 8 dbus, 9 dotnetCorePackages, 10 embree, 11 enet, 12 exportTemplatesHash, 13 fetchFromGitHub, 14 fetchpatch, 15 fontconfig, 16 freetype, 17 gettext, 18 glib, 19 glslang, 20 graphite2, 21 harfbuzz, 22 hash, 23 icu, 24 installShellFiles, 25 lib, 26 libdecor, 27 libGL, 28 libjpeg_turbo, 29 libpulseaudio, 30 libtheora, 31 libwebp, 32 libX11, 33 libXcursor, 34 libXext, 35 libXfixes, 36 libXi, 37 libXinerama, 38 libxkbcommon, 39 libXrandr, 40 libXrender, 41 makeWrapper, 42 mbedtls, 43 miniupnpc, 44 moltenvk, 45 openxr-loader, 46 pcre2, 47 perl, 48 pkg-config, 49 recastnavigation, 50 runCommand, 51 scons, 52 sdl3, 53 speechd-minimal, 54 stdenv, 55 stdenvNoCC, 56 strip-nondeterminism, 57 testers, 58 udev, 59 unzip, 60 updateScript, 61 version, 62 vulkan-loader, 63 wayland, 64 wayland-scanner, 65 withAlsa ? stdenv.hostPlatform.isLinux, 66 withDbus ? true, 67 withFontconfig ? true, 68 withMono ? false, 69 nugetDeps ? null, 70 # only linux supports builtin_ flags properly 71 withBuiltins ? !stdenv.hostPlatform.isLinux, 72 withPlatform ? if stdenv.hostPlatform.isDarwin then "macos" else "linuxbsd", 73 withPrecision ? "single", 74 withPulseaudio ? true, 75 withSpeechd ? true, 76 withTouch ? true, 77 withUdev ? stdenv.hostPlatform.isLinux, 78 # Wayland in Godot requires X11 until upstream fix is merged 79 # https://github.com/godotengine/godot/pull/73504 80 withWayland ? stdenv.hostPlatform.isLinux, 81 withX11 ? stdenv.hostPlatform.isLinux, 82 wslay, 83 zip, 84 zstd, 85}: 86assert lib.asserts.assertOneOf "withPrecision" withPrecision [ 87 "single" 88 "double" 89]; 90let 91 mkSconsFlagsFromAttrSet = lib.mapAttrsToList ( 92 k: v: if builtins.isString v then "${k}=${v}" else "${k}=${builtins.toJSON v}" 93 ); 94 95 arch = stdenv.hostPlatform.linuxArch; 96 97 dotnet-sdk = if withMono then dotnetCorePackages.sdk_8_0-source else null; 98 dotnet-sdk_alt = if withMono then dotnetCorePackages.sdk_9_0-source else null; 99 100 dottedVersion = lib.replaceStrings [ "-" ] [ "." ] version + lib.optionalString withMono ".mono"; 101 102 harfbuzz-icu = harfbuzz.override { withIcu = true; }; 103 104 mkTarget = 105 target: 106 let 107 editor = target == "editor"; 108 suffix = lib.optionalString withMono "-mono" + lib.optionalString (!editor) "-template"; 109 binary = lib.concatStringsSep "." ( 110 [ 111 "godot" 112 withPlatform 113 target 114 ] 115 ++ lib.optional (withPrecision != "single") withPrecision 116 ++ [ arch ] 117 ++ lib.optional withMono "mono" 118 ); 119 120 mkTests = 121 pkg: dotnet-sdk: 122 { 123 version = testers.testVersion { 124 package = pkg; 125 version = dottedVersion; 126 }; 127 } 128 // lib.optionalAttrs editor ( 129 let 130 platform = 131 { 132 linuxbsd = "Linux"; 133 macos = "macOS"; 134 } 135 .${withPlatform}; 136 project-src = 137 runCommand "${pkg.name}-6" 138 { 139 nativeBuildInputs = [ pkg ] ++ lib.optional (dotnet-sdk != null) dotnet-sdk; 140 } 141 ( 142 '' 143 mkdir "$out" 144 cd "$out" 145 touch project.godot 146 147 cat >create-scene.gd <<'EOF' 148 extends SceneTree 149 150 func _initialize(): 151 var node = Node.new() 152 var script = ResourceLoader.load("res://test.gd") 153 node.set_script(script) 154 '' 155 + lib.optionalString withMono '' 156 ${""} 157 var monoNode = Node.new() 158 var monoScript = ResourceLoader.load("res://Test.cs") 159 monoNode.set_script(monoScript) 160 node.add_child(monoNode) 161 monoNode.owner = node 162 '' 163 + '' 164 ${""} 165 var scene = PackedScene.new() 166 var scenePath = "res://test.tscn" 167 scene.pack(node) 168 node.free() 169 var x = ResourceSaver.save(scene, scenePath) 170 ProjectSettings["application/run/main_scene"] = scenePath 171 '' 172 + lib.optionalString stdenv.hostPlatform.isDarwin '' 173 ${""} 174 ProjectSettings["rendering/textures/vram_compression/import_etc2_astc"] = true 175 '' 176 + '' 177 ProjectSettings.save() 178 quit() 179 EOF 180 181 cat >test.gd <<'EOF' 182 extends Node 183 func _ready(): 184 print("Hello, World!") 185 get_tree().quit() 186 EOF 187 188 cat >export_presets.cfg <<'EOF' 189 [preset.0] 190 name="build" 191 platform="${platform}" 192 runnable=true 193 export_filter="all_resources" 194 include_filter="" 195 exclude_filter="" 196 [preset.0.options] 197 binary_format/architecture="${if stdenv.hostPlatform.isDarwin then "universal" else arch}" 198 '' 199 + lib.optionalString stdenv.hostPlatform.isDarwin '' 200 application/bundle_identifier="test" 201 '' 202 + '' 203 EOF 204 '' 205 + lib.optionalString withMono '' 206 cat >Test.cs <<'EOF' 207 using Godot; 208 using System; 209 210 public partial class Test : Node 211 { 212 public override void _Ready() 213 { 214 GD.Print("Hello, Mono!"); 215 GetTree().Quit(); 216 } 217 } 218 EOF 219 220 sdk_version=$(basename ${pkg}/share/nuget/packages/godot.net.sdk/*) 221 cat >UnnamedProject.csproj <<EOF 222 <Project Sdk="Godot.NET.Sdk/$sdk_version"> 223 <PropertyGroup> 224 <TargetFramework>net${lib.versions.majorMinor (lib.defaultTo pkg.dotnet-sdk dotnet-sdk).version}</TargetFramework> 225 <EnableDynamicLoading>true</EnableDynamicLoading> 226 </PropertyGroup> 227 </Project> 228 EOF 229 230 configureNuget 231 232 dotnet new sln -n UnnamedProject 233 message=$(dotnet sln add UnnamedProject.csproj) 234 echo "$message" 235 # dotnet sln doesn't return an error when it fails to add the project 236 [[ $message == "Project \`UnnamedProject.csproj\` added to the solution." ]] 237 238 rm nuget.config 239 '' 240 ); 241 242 export-tests = lib.makeExtensible (final: { 243 inherit (pkg) export-template; 244 245 export = stdenvNoCC.mkDerivation { 246 name = "${final.export-template.name}-export"; 247 248 nativeBuildInputs = [ pkg ] ++ lib.optional (dotnet-sdk != null) dotnet-sdk; 249 250 src = project-src; 251 252 buildPhase = '' 253 runHook preBuild 254 255 export HOME=$(mktemp -d) 256 local dataDir="$HOME/${ 257 if stdenv.hostPlatform.isDarwin then "Library/Application Support/Godot" else ".local/share/godot" 258 }/" 259 mkdir -p "$dataDir" 260 ln -s "${final.export-template}"/share/godot/export_templates "$dataDir" 261 262 godot${suffix} --headless --build-solutions -s create-scene.gd 263 264 runHook postBuild 265 ''; 266 267 installPhase = '' 268 runHook preInstall 269 270 mkdir -p "$out"/bin 271 godot${suffix} --headless --export-release build "$out"/bin/test${lib.optionalString stdenv.hostPlatform.isDarwin ".app"} 272 273 runHook postInstall 274 ''; 275 }; 276 277 run = runCommand "${final.export.name}-runs" { passthru = { inherit (final) export; }; } ( 278 '' 279 ( 280 set -eo pipefail 281 HOME=$(mktemp -d) 282 "${final.export}"/bin/test${lib.optionalString stdenv.hostPlatform.isDarwin ".app/Contents/MacOS/Unnamed"} --headless | tail -n+3 | ( 283 '' 284 + lib.optionalString withMono '' 285 # indent 286 read output 287 if [[ "$output" != "Hello, Mono!" ]]; then 288 echo "unexpected output: $output" >&2 289 exit 1 290 fi 291 '' 292 + '' 293 read output 294 if [[ "$output" != "Hello, World!" ]]; then 295 echo "unexpected output: $output" >&2 296 exit 1 297 fi 298 ) 299 touch "$out" 300 ) 301 '' 302 ); 303 }); 304 305 in 306 { 307 export-runs = export-tests.run; 308 309 export-bin-runs = 310 (export-tests.extend ( 311 final: prev: { 312 export-template = pkg.export-templates-bin; 313 314 export = prev.export.overrideAttrs (prev: { 315 nativeBuildInputs = 316 prev.nativeBuildInputs or [ ] ++ lib.optional stdenv.hostPlatform.isElf autoPatchelfHook; 317 318 # stripping dlls results in: 319 # Failed to load System.Private.CoreLib.dll (error code 0x8007000B) 320 stripExclude = lib.optional withMono [ "*.dll" ]; 321 322 runtimeDependencies = 323 prev.runtimeDependencies or [ ] 324 ++ map lib.getLib [ 325 libpulseaudio 326 libX11 327 libXcursor 328 libXext 329 libXi 330 libXrandr 331 vulkan-loader 332 ] 333 ++ lib.optionals stdenv.hostPlatform.isLinux [ 334 alsa-lib 335 udev 336 ]; 337 }); 338 } 339 )).run; 340 } 341 ); 342 343 attrs = finalAttrs: rec { 344 pname = "godot${suffix}"; 345 inherit version; 346 347 src = fetchFromGitHub { 348 owner = "godotengine"; 349 repo = "godot"; 350 tag = version; 351 inherit hash; 352 # Required for the commit hash to be included in the version number. 353 # 354 # `methods.py` reads the commit hash from `.git/HEAD` and manually follows 355 # refs. 356 # 357 # See also 'hash' in 358 # https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info 359 leaveDotGit = true; 360 # Only keep HEAD, because leaveDotGit is non-deterministic: 361 # https://github.com/NixOS/nixpkgs/issues/8567 362 postFetch = '' 363 hash=$(git -C "$out" rev-parse HEAD) 364 rm -r "$out"/.git 365 mkdir "$out"/.git 366 echo "$hash" > "$out"/.git/HEAD 367 ''; 368 }; 369 370 outputs = [ 371 "out" 372 ] 373 ++ lib.optional editor "man"; 374 separateDebugInfo = true; 375 376 # Set the build name which is part of the version. In official downloads, this 377 # is set to 'official'. When not specified explicitly, it is set to 378 # 'custom_build'. Other platforms packaging Godot (Gentoo, Arch, Flatpack 379 # etc.) usually set this to their name as well. 380 # 381 # See also 'methods.py' in the Godot repo and 'build' in 382 # https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info 383 BUILD_NAME = "nixpkgs"; 384 385 preConfigure = lib.optionalString (editor && withMono) '' 386 # TODO: avoid pulling in dependencies of windows-only project 387 dotnet sln modules/mono/editor/GodotTools/GodotTools.sln \ 388 remove modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj 389 390 dotnet restore modules/mono/glue/GodotSharp/GodotSharp.sln 391 dotnet restore modules/mono/editor/GodotTools/GodotTools.sln 392 dotnet restore modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln 393 ''; 394 395 # darwin needs $HOME/.cache/clang/ModuleCache 396 preBuild = lib.optionalString stdenv.hostPlatform.isDarwin '' 397 export HOME=$(mktemp -d) 398 ''; 399 400 # From: https://github.com/godotengine/godot/blob/4.2.2-stable/SConstruct 401 sconsFlags = mkSconsFlagsFromAttrSet ( 402 { 403 # Options from 'SConstruct' 404 precision = withPrecision; # Floating-point precision level 405 production = true; # Set defaults to build Godot for use in production 406 platform = withPlatform; 407 inherit target; 408 debug_symbols = true; 409 410 # Options from 'platform/linuxbsd/detect.py' 411 alsa = withAlsa; 412 dbus = withDbus; # Use D-Bus to handle screensaver and portal desktop settings 413 fontconfig = withFontconfig; # Use fontconfig for system fonts support 414 pulseaudio = withPulseaudio; # Use PulseAudio 415 speechd = withSpeechd; # Use Speech Dispatcher for Text-to-Speech support 416 touch = withTouch; # Enable touch events 417 udev = withUdev; # Use udev for gamepad connection callbacks 418 wayland = withWayland; # Compile with Wayland support 419 x11 = withX11; # Compile with X11 support 420 421 module_mono_enabled = withMono; 422 423 # aliasing bugs exist with hardening+LTO 424 # https://github.com/godotengine/godot/pull/104501 425 ccflags = "-fno-strict-aliasing"; 426 # on darwin: ld: unknown option: --build-id 427 linkflags = lib.optionalString (!stdenv.hostPlatform.isDarwin) "-Wl,--build-id"; 428 429 # libraries that aren't available in nixpkgs 430 builtin_msdfgen = true; 431 builtin_rvo2_2d = true; 432 builtin_rvo2_3d = true; 433 builtin_xatlas = true; 434 435 # using system clipper2 is currently not implemented 436 builtin_clipper2 = true; 437 438 use_sowrap = false; 439 } 440 // lib.optionalAttrs (lib.versionOlder version "4.4") { 441 # libraries that aren't available in nixpkgs 442 builtin_squish = true; 443 444 # broken with system packages 445 builtin_miniupnpc = true; 446 } 447 // lib.optionalAttrs (lib.versionAtLeast version "4.5") { 448 redirect_build_objects = false; # Avoid copying build objects to output 449 } 450 // lib.optionalAttrs stdenv.hostPlatform.isDarwin { 451 generate_bundle = "yes"; 452 } 453 ); 454 455 enableParallelBuilding = true; 456 457 strictDeps = true; 458 459 propagatedSandboxProfile = lib.optionalString stdenv.hostPlatform.isDarwin '' 460 (allow file-read* (subpath "/System/Library/CoreServices/SystemAppearance.bundle")) 461 ''; 462 463 patches = [ 464 ./Linux-fix-missing-library-with-builtin_glslang-false.patch 465 ] 466 ++ lib.optionals (lib.versionAtLeast version "4.6") [ 467 # https://github.com/godotengine/godot/pull/115450 468 (fetchpatch { 469 name = "fix-tls-handshake-fail-preventing-assetlib-use.patch"; 470 url = "https://github.com/godotengine/godot/commit/29acd734c71f06268d6ef4715d7df70b14731f48.patch"; 471 hash = "sha256-wxkr6jPtutUTG+mYrXoxcDcWIIZghlSJ79XqhFh/0P4="; 472 }) 473 ] 474 ++ lib.optionals (lib.versionOlder version "4.4") [ 475 (fetchpatch { 476 name = "wayland-header-fix.patch"; 477 url = "https://github.com/godotengine/godot/commit/6ce71f0fb0a091cffb6adb4af8ab3f716ad8930b.patch"; 478 hash = "sha256-hgAtAtCghF5InyGLdE9M+9PjPS1BWXWGKgIAyeuqkoU="; 479 }) 480 (fetchpatch { 481 name = "thorvg-header-fix.patch"; 482 url = "https://github.com/godotengine/godot/commit/1823460787a6c1bb8e4eaf21ac2a3f90d24d5ee0.patch"; 483 hash = "sha256-PcHEMXd0v2c3j6Eitxt5uWi6cD+OmsBAn3TNMNRNPog="; 484 }) 485 # Fix a crash in the mono test project build. It no longer seems to 486 # happen in 4.4, but an existing fix couldn't be identified. 487 ./CSharpLanguage-fix-crash-in-reload_assemblies-after-.patch 488 ] 489 ++ lib.optional ( 490 stdenv.hostPlatform.isDarwin && lib.versionAtLeast version "4.4" 491 ) ./fix-moltenvk-detection.patch; 492 493 postPatch = '' 494 # this stops scons from hiding e.g. NIX_CFLAGS_COMPILE 495 perl -pi -e '{ $r += s:(env = Environment\(.*):\1\nenv["ENV"] = os.environ: } END { exit ($r != 1) }' SConstruct 496 497 '' 498 + lib.optionalString (!withBuiltins) '' 499 # disable all builtin libraries by default 500 perl -pi -e '{ $r |= s:(opts.Add\(BoolVariable\("builtin_.*, )True(\)\)):\1False\2: } END { exit ($r != 1) }' SConstruct 501 502 '' 503 + lib.optionalString (lib.versionOlder version "4.6") '' 504 substituteInPlace platform/linuxbsd/detect.py \ 505 --replace-fail /usr/include/recastnavigation ${lib.escapeShellArg (lib.getDev recastnavigation)}/include/recastnavigation 506 '' 507 + lib.optionalString (libGL != null) '' 508 substituteInPlace thirdparty/glad/egl.c \ 509 --replace-fail \ 510 'static const char *NAMES[] = {"libEGL.so.1", "libEGL.so"}' \ 511 'static const char *NAMES[] = {"${lib.getLib libGL}/lib/libEGL.so"}' 512 513 substituteInPlace thirdparty/glad/gl.c \ 514 --replace-fail \ 515 'static const char *NAMES[] = {"libGLESv2.so.2", "libGLESv2.so"}' \ 516 'static const char *NAMES[] = {"${lib.getLib libGL}/lib/libGLESv2.so"}' \ 517 518 substituteInPlace thirdparty/glad/gl{,x}.c \ 519 --replace-fail \ 520 '"libGL.so.1"' \ 521 '"${lib.getLib libGL}/lib/libGL.so"' 522 '' 523 + '' 524 substituteInPlace thirdparty/volk/volk.c \ 525 --replace-fail \ 526 'dlopen("libvulkan.so.1"' \ 527 'dlopen("${lib.getLib vulkan-loader}/lib/libvulkan.so"' 528 '' 529 + lib.optionalString stdenv.hostPlatform.isDarwin ( 530 '' 531 substituteInPlace platform/macos/export/export_plugin.cpp \ 532 --replace-fail \ 533 /usr/bin/codesign \ 534 '${lib.getExe' darwin.sigtool "sigtool"}' 535 '' 536 # https://github.com/godotengine/godot/issues/107199 537 + lib.optionalString (lib.versionAtLeast version "4.5") '' 538 substituteInPlace drivers/metal/SCsub \ 539 --replace-fail \ 540 'env_metal.Append(CCFLAGS=["-fmodules", "-fcxx-modules"])' \ 541 "" 542 '' 543 # godot zips these files and fails if mtime < 1980 544 + lib.optionalString (!editor) '' 545 find misc/dist/macos_template.app -exec touch {} \; 546 '' 547 ); 548 549 depsBuildBuild = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ 550 buildPackages.stdenv.cc 551 pkg-config 552 ]; 553 554 env.NIX_CFLAGS_COMPILE = toString ( 555 lib.optionals stdenv.hostPlatform.isDarwin [ 556 "-I${lib.getDev harfbuzz-icu}/include/harfbuzz" 557 "-I${lib.getDev recastnavigation}/include/recastnavigation" 558 ] 559 ); 560 561 buildInputs = 562 lib.optionals (!withBuiltins) ( 563 [ 564 embree 565 enet 566 freetype 567 glslang 568 graphite2 569 harfbuzz-icu 570 icu 571 libtheora 572 libwebp 573 mbedtls 574 miniupnpc 575 openxr-loader 576 pcre2 577 recastnavigation 578 wslay 579 zstd 580 ] 581 ++ lib.optionals (lib.versionAtLeast version "4.5") [ 582 libjpeg_turbo 583 sdl3 584 ] 585 ) 586 ++ lib.optionals (editor && withMono) dotnet-sdk.packages 587 ++ lib.optional withAlsa alsa-lib 588 ++ lib.optional (withX11 || withWayland) libxkbcommon 589 ++ lib.optionals withX11 [ 590 libX11 591 libXcursor 592 libXext 593 libXfixes 594 libXi 595 libXinerama 596 libXrandr 597 libXrender 598 ] 599 ++ lib.optionals withWayland [ 600 libdecor 601 wayland 602 ] 603 ++ lib.optionals withDbus [ 604 dbus 605 ] 606 ++ lib.optionals withFontconfig [ 607 fontconfig 608 ] 609 ++ lib.optional withPulseaudio libpulseaudio 610 ++ lib.optionals withSpeechd [ 611 speechd-minimal 612 glib 613 ] 614 ++ lib.optional withUdev udev 615 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 616 apple-sdk_26 617 moltenvk 618 ]; 619 620 nativeBuildInputs = [ 621 gettext 622 installShellFiles 623 perl 624 pkg-config 625 scons 626 ] 627 ++ lib.optionals withWayland [ wayland-scanner ] 628 ++ lib.optional (editor && withMono) [ 629 makeWrapper 630 dotnet-sdk 631 ] 632 ++ lib.optionals stdenv.hostPlatform.isDarwin ( 633 [ 634 darwin.sigtool 635 ] 636 ++ lib.optionals (!editor) [ 637 strip-nondeterminism 638 unzip 639 zip 640 ] 641 ); 642 643 postBuild = lib.optionalString (editor && withMono) '' 644 echo "Generating Glue" 645 bin/${binary} --headless --generate-mono-glue modules/mono/glue 646 echo "Building C#/.NET Assemblies" 647 python modules/mono/build_scripts/build_assemblies.py --godot-output-dir bin --precision=${withPrecision} 648 ''; 649 650 installPhase = '' 651 runHook preInstall 652 653 mkdir -p "$out"/{bin,libexec} 654 cp -r bin/${binary} "$out"/libexec/ 655 656 cd "$out"/bin 657 ln -s ../libexec/${binary} godot${lib.versions.majorMinor version}${suffix} 658 ln -s godot${lib.versions.majorMinor version}${suffix} godot${lib.versions.major version}${suffix} 659 ln -s godot${lib.versions.major version}${suffix} godot${suffix} 660 cd - 661 '' 662 + ( 663 if editor then 664 '' 665 installManPage misc/dist/linux/godot.6 666 667 mkdir -p "$out"/share/{applications,icons/hicolor/scalable/apps} 668 cp misc/dist/linux/org.godotengine.Godot.desktop \ 669 "$out/share/applications/org.godotengine.Godot${lib.versions.majorMinor version}${suffix}.desktop" 670 671 substituteInPlace "$out/share/applications/org.godotengine.Godot${lib.versions.majorMinor version}${suffix}.desktop" \ 672 --replace-fail "Exec=godot" "Exec=$out/bin/godot${suffix}" \ 673 --replace-fail "Godot Engine" "Godot Engine ${ 674 lib.versions.majorMinor version + lib.optionalString withMono " (Mono)" 675 }" 676 cp icon.svg "$out/share/icons/hicolor/scalable/apps/godot.svg" 677 cp icon.png "$out/share/icons/godot.png" 678 '' 679 + lib.optionalString withMono '' 680 cp -r bin/GodotSharp "$out"/libexec/ 681 mkdir -p "$out"/share/nuget 682 mv "$out"/libexec/GodotSharp/Tools/nupkgs "$out"/share/nuget/source 683 684 wrapProgram "$out"/libexec/${binary} \ 685 --prefix NUGET_FALLBACK_PACKAGES ';' "$out"/share/nuget/packages/ 686 '' 687 + lib.optionalString stdenv.hostPlatform.isDarwin '' 688 mkdir -p "$out"/Applications 689 cp -r bin/godot_macos_editor.app "$out"/Applications/Godot.app 690 '' 691 else 692 let 693 template = 694 (lib.replaceStrings 695 [ "template" ] 696 [ 697 { 698 linuxbsd = "linux"; 699 macos = "macos"; 700 } 701 .${withPlatform} 702 ] 703 target 704 ) 705 + "." 706 + arch; 707 in 708 '' 709 templates="$out"/share/godot/export_templates/${dottedVersion} 710 mkdir -p "$templates" 711 ln -s "$out"/libexec/${binary} "$templates"/${template} 712 '' 713 # TODO: teach godot to use a template that isn't zipped. for now we 714 # just need to make it uncompressed so it doesn't break dependencies 715 + lib.optionalString stdenv.hostPlatform.isDarwin '' 716 cd bin 717 unzip godot_macos${lib.optionalString withMono "_mono"}.zip 718 zip -rq0 "$templates"/macos.zip macos_template.app 719 strip-nondeterminism --type zip "$templates"/macos.zip 720 cd - 721 '' 722 ) 723 + '' 724 runHook postInstall 725 ''; 726 727 passthru = { 728 inherit updateScript; 729 tests = 730 mkTests finalAttrs.finalPackage dotnet-sdk 731 // lib.optionalAttrs (editor && withMono) { 732 sdk-override = mkTests finalAttrs.finalPackage dotnet-sdk_alt; 733 }; 734 } 735 // lib.optionalAttrs editor { 736 export-template = mkTarget "template_release"; 737 export-templates-bin = ( 738 callPackage ./export-templates-bin.nix { 739 inherit version withMono; 740 godot = finalAttrs.finalPackage; 741 hash = exportTemplatesHash; 742 } 743 ); 744 }; 745 746 requiredSystemFeatures = [ 747 # fixes: No space left on device 748 "big-parallel" 749 ]; 750 751 meta = { 752 changelog = "https://github.com/godotengine/godot/releases/tag/${version}"; 753 description = "Free and Open Source 2D and 3D game engine"; 754 homepage = "https://godotengine.org"; 755 license = lib.licenses.mit; 756 platforms = [ 757 "x86_64-linux" 758 "aarch64-linux" 759 ] 760 ++ lib.optional (!withMono) "i686-linux" 761 # 4.3 doesn't compile on darwin, and 4.4 doesn't pass tests 762 ++ lib.optionals (lib.versionAtLeast version "4.5") [ 763 "x86_64-darwin" 764 "aarch64-darwin" 765 ]; 766 maintainers = with lib.maintainers; [ 767 shiryel 768 corngood 769 ]; 770 mainProgram = "godot${suffix}"; 771 }; 772 }; 773 774 unwrapped = stdenv.mkDerivation ( 775 if (editor && withMono) then 776 dotnetCorePackages.addNuGetDeps { 777 inherit nugetDeps; 778 overrideFetchAttrs = old: rec { 779 runtimeIds = map (system: dotnetCorePackages.systemToDotnetRid system) old.meta.platforms; 780 buildInputs = 781 old.buildInputs 782 ++ lib.concatLists (lib.attrValues (lib.getAttrs runtimeIds dotnet-sdk.targetPackages)); 783 }; 784 } attrs 785 else 786 attrs 787 ); 788 789 wrapper = 790 if (editor && withMono) then 791 stdenv.mkDerivation (finalAttrs: { 792 __structuredAttrs = true; 793 794 pname = finalAttrs.unwrapped.pname + "-wrapper"; 795 inherit (finalAttrs.unwrapped) version outputs meta; 796 inherit unwrapped dotnet-sdk; 797 798 dontUnpack = true; 799 dontConfigure = true; 800 dontBuild = true; 801 802 nativeBuildInputs = [ makeWrapper ]; 803 strictDeps = true; 804 805 installPhase = '' 806 runHook preInstall 807 808 mkdir -p "$out"/{bin,libexec,share/applications,nix-support} 809 810 cp -d "$unwrapped"/bin/* "$out"/bin/ 811 ln -s "$unwrapped"/libexec/* "$out"/libexec/ 812 ln -s "$unwrapped"/share/nuget "$out"/share/ 813 cp "$unwrapped/share/applications/org.godotengine.Godot${lib.versions.majorMinor version}${suffix}.desktop" \ 814 "$out/share/applications/org.godotengine.Godot${lib.versions.majorMinor version}${suffix}.desktop" 815 816 substituteInPlace "$out/share/applications/org.godotengine.Godot${lib.versions.majorMinor version}${suffix}.desktop" \ 817 --replace-fail "Exec=$unwrapped/bin/godot${suffix}" "Exec=$out/bin/godot${suffix}" 818 ln -s "$unwrapped"/share/icons $out/share/ 819 820 # ensure dotnet hooks get run 821 echo "${finalAttrs.dotnet-sdk}" >> "$out"/nix-support/propagated-build-inputs 822 823 wrapProgram "$out"/libexec/${binary} \ 824 --prefix PATH : "${lib.makeBinPath [ finalAttrs.dotnet-sdk ]}" 825 826 runHook postInstall 827 ''; 828 829 postFixup = lib.concatMapStringsSep "\n" (output: '' 830 [[ -e "''$${output}" ]] || ln -s "${unwrapped.${output}}" "''$${output}" 831 '') finalAttrs.unwrapped.outputs; 832 833 passthru = unwrapped.passthru // { 834 tests = mkTests finalAttrs.finalPackage null // { 835 unwrapped = lib.recurseIntoAttrs unwrapped.tests; 836 sdk-override = lib.recurseIntoAttrs ( 837 mkTests (finalAttrs.finalPackage.overrideAttrs { dotnet-sdk = dotnet-sdk_alt; }) null 838 ); 839 }; 840 }; 841 }) 842 else 843 unwrapped; 844 in 845 wrapper; 846in 847mkTarget "editor"