diff --git a/doc/release-notes/rl-2505.section.md b/doc/release-notes/rl-2505.section.md index 63153c27fb6a..afa4d0e3474e 100644 --- a/doc/release-notes/rl-2505.section.md +++ b/doc/release-notes/rl-2505.section.md @@ -424,6 +424,8 @@ - [`lib.packagesFromDirectoryRecursive`] now rejects unknown arguments. [`lib.packagesFromDirectoryRecursive`]: https://nixos.org/manual/nixpkgs/stable/#function-library-lib.filesystem.packagesFromDirectoryRecursive +- The `godot-export-templates` package now has its content at `share/godot/export_templates/$version` instead of the output root. This makes it more convenient for for symlinking into `~/.local`, but scripts expecting the old layout will need to be changed. + ### Deprecations {#sec-nixpkgs-release-25.05-lib-deprecations} - `functor` is an implementation detail and should not be relied upon, but since its status wasn't clear and it has had some use cases without alternatives, changes are being handled as gracefully as possible. Deprecations within functor: diff --git a/pkgs/by-name/op/opengamepadui/package.nix b/pkgs/by-name/op/opengamepadui/package.nix index 00ed2c02d1a6..497f1e03eda1 100644 --- a/pkgs/by-name/op/opengamepadui/package.nix +++ b/pkgs/by-name/op/opengamepadui/package.nix @@ -1,6 +1,5 @@ { alsa-lib, - autoPatchelfHook, cargo, dbus, fetchFromGitHub, @@ -43,34 +42,12 @@ stdenv.mkDerivation (finalAttrs: { cargoRoot = "extensions"; nativeBuildInputs = [ - autoPatchelfHook cargo godot_4_4 - godot_4_4.export-templates-bin pkg-config rustPlatform.cargoSetupHook ]; - runtimeDependencies = [ - alsa-lib - dbus - gamescope - hwdata - libGL - libpulseaudio - mesa-demos - udev - upower - vulkan-loader - xorg.libX11 - xorg.libXcursor - xorg.libXext - xorg.libXi - xorg.libXrandr - xorg.libXres - xorg.libXtst - ]; - dontStrip = withDebug; env = @@ -81,7 +58,7 @@ stdenv.mkDerivation (finalAttrs: { GODOT = lib.getExe godot_4_4; GODOT_VERSION = lib.elemAt versionAndRelease 0; GODOT_RELEASE = lib.elemAt versionAndRelease 1; - EXPORT_TEMPLATE = "${godot_4_4.export-templates-bin}"; + EXPORT_TEMPLATE = "${godot_4_4.export-template}/share/godot/export_templates"; BUILD_TYPE = "${finalAttrs.buildType}"; }; @@ -92,15 +69,26 @@ stdenv.mkDerivation (finalAttrs: { preBuild = '' # Godot looks for export templates in HOME export HOME=$(mktemp -d) - mkdir -p $HOME/.local/share/godot/export_templates - ln -s "${godot_4_4.export-templates-bin}" "$HOME/.local/share/godot/export_templates/$GODOT_VERSION.$GODOT_RELEASE" + mkdir -p $HOME/.local/share/godot/ + ln -s "$EXPORT_TEMPLATE" "$HOME"/.local/share/godot/ ''; - postInstall = '' - # The Godot binary looks in "../lib" for gdextensions - mkdir -p $out/share/lib - mv $out/share/opengamepadui/*.so $out/share/lib - ''; + postInstall = + let + runtimeDependencies = [ + gamescope + hwdata + mesa-demos + udev + upower + ]; + in + '' + # The Godot binary looks in "../lib" for gdextensions + mkdir -p $out/share/lib + mv $out/share/opengamepadui/*.so $out/share/lib + patchelf --add-rpath ${lib.makeLibraryPath runtimeDependencies} $out/share/lib/*.so + ''; passthru.updateScript = nix-update-script { }; diff --git a/pkgs/by-name/pi/pixelorama/package.nix b/pkgs/by-name/pi/pixelorama/package.nix index 5443e94a527d..2d4553403e37 100644 --- a/pkgs/by-name/pi/pixelorama/package.nix +++ b/pkgs/by-name/pi/pixelorama/package.nix @@ -1,20 +1,9 @@ { lib, stdenv, - alsa-lib, - autoPatchelfHook, fetchFromGitHub, godot_4_3, - libGL, - libpulseaudio, - libX11, - libXcursor, - libXext, - libXi, - libXrandr, nix-update-script, - udev, - vulkan-loader, }: let @@ -28,7 +17,6 @@ let or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); godot = godot_4_3; - godot_version_folder = lib.replaceStrings [ "-" ] [ "." ] godot.version; in stdenv.mkDerivation (finalAttrs: { pname = "pixelorama"; @@ -44,29 +32,15 @@ stdenv.mkDerivation (finalAttrs: { strictDeps = true; nativeBuildInputs = [ - autoPatchelfHook godot ]; - runtimeDependencies = map lib.getLib [ - alsa-lib - libGL - libpulseaudio - libX11 - libXcursor - libXext - libXi - libXrandr - udev - vulkan-loader - ]; - buildPhase = '' runHook preBuild export HOME=$(mktemp -d) - mkdir -p $HOME/.local/share/godot/export_templates - ln -s "${godot.export-templates-bin}" "$HOME/.local/share/godot/export_templates/${godot_version_folder}" + mkdir -p $HOME/.local/share/godot/ + ln -s "${godot.export-template}"/share/godot/export_templates "$HOME"/.local/share/godot/ mkdir -p build godot4 --headless --export-release "${preset}" ./build/pixelorama diff --git a/pkgs/development/tools/godot/4.3/default.nix b/pkgs/development/tools/godot/4.3/default.nix index 47f3bafbb2e6..314acfcdb99d 100644 --- a/pkgs/development/tools/godot/4.3/default.nix +++ b/pkgs/development/tools/godot/4.3/default.nix @@ -1,6 +1,11 @@ { version = "4.3-stable"; hash = "sha256-MzElflwXHWLgPtoOIhPLA00xX8eEdQsexZaGIEOzbj0="; - exportTemplatesHash = "sha256-XRnKii+eexIkbGf7bqc42SR0NBULFvgMdOpSRNNk6kg="; - nugetDeps = ./deps.json; + default = { + exportTemplatesHash = "sha256-9fENuvVqeQg0nmS5TqjCyTwswR+xAUyVZbaKK7Q3uSI="; + }; + mono = { + exportTemplatesHash = "sha256-pkDZfkJHiDtY05TGERwTNDES88SbuFfZVYb5hln6O+U="; + nugetDeps = ./deps.json; + }; } diff --git a/pkgs/development/tools/godot/4.4/default.nix b/pkgs/development/tools/godot/4.4/default.nix index 469d543f8494..90d403352170 100644 --- a/pkgs/development/tools/godot/4.4/default.nix +++ b/pkgs/development/tools/godot/4.4/default.nix @@ -1,6 +1,11 @@ { version = "4.4.1-stable"; hash = "sha256-O4TdPYu1K2zWKMBP/7xd0UPLDb7/4dBnkGM7QydD3Yo="; - exportTemplatesHash = "sha256-KV4sDBZPiMf7IORaNFR2uEK1midnyyjCUfG9hl6AwHY="; - nugetDeps = ./deps.json; + default = { + exportTemplatesHash = "sha256-eo0UreSJ/U0i8XgZMCH+iodqnlEGjtTd4m2sOuTFmog="; + }; + mono = { + exportTemplatesHash = "sha256-tk0WS5axndcXWhuj86blg+nU3FB7PRMzVj8ka1gRgj4="; + nugetDeps = ./deps.json; + }; } diff --git a/pkgs/development/tools/godot/CSharpLanguage-fix-crash-in-reload_assemblies-after-.patch b/pkgs/development/tools/godot/CSharpLanguage-fix-crash-in-reload_assemblies-after-.patch new file mode 100644 index 000000000000..b42f99dff966 --- /dev/null +++ b/pkgs/development/tools/godot/CSharpLanguage-fix-crash-in-reload_assemblies-after-.patch @@ -0,0 +1,30 @@ +From 42f89dd50dde0896d6c55282c82db9af41cd12d8 Mon Sep 17 00:00:00 2001 +From: David McFarland +Date: Wed, 26 Mar 2025 09:52:17 -0300 +Subject: [PATCH] CSharpLanguage: fix crash in reload_assemblies after editor + shutdown + +--- + modules/mono/csharp_script.cpp | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp +index 36c8a40ed9..2b161fb69b 100644 +--- a/modules/mono/csharp_script.cpp ++++ b/modules/mono/csharp_script.cpp +@@ -1001,8 +1001,10 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { + #ifdef TOOLS_ENABLED + // FIXME: Hack to refresh editor in order to display new properties and signals. See if there is a better alternative. + if (Engine::get_singleton()->is_editor_hint()) { +- InspectorDock::get_inspector_singleton()->update_tree(); +- NodeDock::get_singleton()->update_lists(); ++ if (InspectorDock::get_singleton()) ++ InspectorDock::get_inspector_singleton()->update_tree(); ++ if (NodeDock::get_singleton()) ++ NodeDock::get_singleton()->update_lists(); + } + #endif + } +-- +2.48.1 + diff --git a/pkgs/development/tools/godot/common.nix b/pkgs/development/tools/godot/common.nix index bab845d6af5d..40a4682bfd00 100644 --- a/pkgs/development/tools/godot/common.nix +++ b/pkgs/development/tools/godot/common.nix @@ -2,10 +2,14 @@ alsa-lib, autoPatchelfHook, buildPackages, + callPackage, dbus, dotnetCorePackages, + exportTemplatesHash, fetchFromGitHub, + fetchpatch, fontconfig, + glib, hash, installShellFiles, lib, @@ -22,6 +26,7 @@ libXrandr, libXrender, makeWrapper, + perl, pkg-config, runCommand, scons, @@ -30,10 +35,12 @@ stdenvNoCC, testers, udev, + updateScript, version, vulkan-loader, wayland, wayland-scanner, + withAlsa ? true, withDbus ? true, withFontconfig ? true, withMono ? false, @@ -42,7 +49,6 @@ withPrecision ? "single", withPulseaudio ? true, withSpeechd ? true, - withTarget ? "editor", withTouch ? true, withUdev ? true, # Wayland in Godot requires X11 until upstream fix is merged @@ -59,348 +65,525 @@ let k: v: if builtins.isString v then "${k}=${v}" else "${k}=${builtins.toJSON v}" ); - suffix = if withMono then "-mono" else ""; - arch = stdenv.hostPlatform.linuxArch; dotnet-sdk = dotnetCorePackages.sdk_8_0-source; - attrs = finalAttrs: rec { - pname = "godot4${suffix}"; - inherit version; + dottedVersion = lib.replaceStrings [ "-" ] [ "." ] version + lib.optionalString withMono ".mono"; - src = fetchFromGitHub { - owner = "godotengine"; - repo = "godot"; - tag = version; - inherit hash; - # Required for the commit hash to be included in the version number. - # - # `methods.py` reads the commit hash from `.git/HEAD` and manually follows - # refs. - # - # See also 'hash' in - # https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info - leaveDotGit = true; - # Only keep HEAD, because leaveDotGit is non-deterministic: - # https://github.com/NixOS/nixpkgs/issues/8567 - postFetch = '' - hash=$(git -C "$out" rev-parse HEAD) - rm -r "$out"/.git - mkdir "$out"/.git - echo "$hash" > "$out"/.git/HEAD - ''; - }; + attrsForTarget = + target: finalAttrs: + let + editor = target == "editor"; + suffix = lib.optionalString withMono "-mono" + lib.optionalString (!editor) "-template"; + binary = lib.concatStringsSep "." ( + [ + "godot" + withPlatform + target + ] + ++ lib.optional (withPrecision != "single") withPrecision + ++ [ arch ] + ++ lib.optional withMono "mono" + ); + in + rec { + pname = "godot${suffix}"; + inherit version; - outputs = [ - "out" - "man" - ]; - separateDebugInfo = true; - - # Set the build name which is part of the version. In official downloads, this - # is set to 'official'. When not specified explicitly, it is set to - # 'custom_build'. Other platforms packaging Godot (Gentoo, Arch, Flatpack - # etc.) usually set this to their name as well. - # - # See also 'methods.py' in the Godot repo and 'build' in - # https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info - BUILD_NAME = "nixpkgs"; - - preConfigure = lib.optionalString withMono '' - # TODO: avoid pulling in dependencies of windows-only project - dotnet sln modules/mono/editor/GodotTools/GodotTools.sln \ - remove modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj - - dotnet restore modules/mono/glue/GodotSharp/GodotSharp.sln - dotnet restore modules/mono/editor/GodotTools/GodotTools.sln - dotnet restore modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln - ''; - - # From: https://github.com/godotengine/godot/blob/4.2.2-stable/SConstruct - sconsFlags = mkSconsFlagsFromAttrSet { - # Options from 'SConstruct' - precision = withPrecision; # Floating-point precision level - production = true; # Set defaults to build Godot for use in production - platform = withPlatform; - target = withTarget; - debug_symbols = true; - - # Options from 'platform/linuxbsd/detect.py' - dbus = withDbus; # Use D-Bus to handle screensaver and portal desktop settings - fontconfig = withFontconfig; # Use fontconfig for system fonts support - pulseaudio = withPulseaudio; # Use PulseAudio - speechd = withSpeechd; # Use Speech Dispatcher for Text-to-Speech support - touch = withTouch; # Enable touch events - udev = withUdev; # Use udev for gamepad connection callbacks - wayland = withWayland; # Compile with Wayland support - x11 = withX11; # Compile with X11 support - - module_mono_enabled = withMono; - - linkflags = "-Wl,--build-id"; - }; - - enableParallelBuilding = true; - - strictDeps = true; - - depsBuildBuild = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ - buildPackages.stdenv.cc - pkg-config - ]; - - buildInputs = lib.optionals withMono dotnet-sdk.packages; - - nativeBuildInputs = - [ - autoPatchelfHook - installShellFiles - pkg-config - scons - ] - ++ lib.optionals withWayland [ wayland-scanner ] - ++ lib.optionals withMono [ - dotnet-sdk - makeWrapper - ]; - - postBuild = lib.optionalString withMono '' - echo "Generating Glue" - if [[ ${withPrecision} == *double* ]]; then - bin/godot.${withPlatform}.${withTarget}.${withPrecision}.${arch}.mono --headless --generate-mono-glue modules/mono/glue - else - bin/godot.${withPlatform}.${withTarget}.${arch}.mono --headless --generate-mono-glue modules/mono/glue - fi - echo "Building C#/.NET Assemblies" - python modules/mono/build_scripts/build_assemblies.py --godot-output-dir bin --precision=${withPrecision} - ''; - - runtimeDependencies = - [ - alsa-lib - libGL - vulkan-loader - ] - ++ lib.optionals withX11 [ - libX11 - libXcursor - libXext - libXfixes - libXi - libXinerama - libxkbcommon - libXrandr - libXrender - ] - ++ lib.optionals withWayland [ - libdecor - wayland - ] - ++ lib.optionals withDbus [ - dbus - dbus.lib - ] - ++ lib.optionals withFontconfig [ - fontconfig - fontconfig.lib - ] - ++ lib.optionals withPulseaudio [ libpulseaudio ] - ++ lib.optionals withSpeechd [ speechd-minimal ] - ++ lib.optionals withUdev [ udev ]; - - installPhase = - '' - runHook preInstall - - mkdir -p "$out/bin" - cp bin/godot.* $out/bin/godot4${suffix} - - installManPage misc/dist/linux/godot.6 - - mkdir -p "$out"/share/{applications,icons/hicolor/scalable/apps} - cp misc/dist/linux/org.godotengine.Godot.desktop "$out/share/applications/org.godotengine.Godot4${suffix}.desktop" - substituteInPlace "$out/share/applications/org.godotengine.Godot4${suffix}.desktop" \ - --replace "Exec=godot" "Exec=$out/bin/godot4${suffix}" \ - --replace "Godot Engine" "Godot Engine 4" - cp icon.svg "$out/share/icons/hicolor/scalable/apps/godot.svg" - cp icon.png "$out/share/icons/godot.png" - '' - + lib.optionalString withMono '' - cp -r bin/GodotSharp/ $out/bin/ - wrapProgram $out/bin/godot4${suffix} \ - --set DOTNET_ROOT ${dotnet-sdk} \ - --prefix PATH : "${ - lib.makeBinPath [ - dotnet-sdk - ] - }" - '' - + '' - ln -s godot4${suffix} "$out"/bin/godot - runHook post Install - ''; - - # patching $debug can crash patchelf - # (https://github.com/NixOS/patchelf/issues/373), so explicitly patch $out - dontAutoPatchelf = true; - - postFixup = '' - autoPatchelf "$out" - ''; - - passthru = { - tests = - let - pkg = finalAttrs.finalPackage; - dottedVersion = lib.replaceStrings [ "-" ] [ "." ] version; - exportedProject = stdenvNoCC.mkDerivation { - name = "${pkg.name}-project-export"; - - nativeBuildInputs = [ - pkg - autoPatchelfHook - ]; - - runtimeDependencies = map lib.getLib [ - alsa-lib - libGL - libpulseaudio - libX11 - libXcursor - libXext - libXi - libXrandr - udev - vulkan-loader - ]; - - unpackPhase = '' - runHook preUnpack - - mkdir test - cd test - touch project.godot - - cat >create-scene.gd <<'EOF' - extends SceneTree - - func _initialize(): - var node = Node.new() - var script = ResourceLoader.load("res://test.gd") - print(script) - node.set_script(script) - var scene = PackedScene.new() - var scenePath = "res://test.tscn" - scene.pack(node) - var x = ResourceSaver.save(scene, scenePath) - ProjectSettings["application/run/main_scene"] = scenePath - ProjectSettings.save() - node.free() - quit() - EOF - - cat >test.gd <<'EOF' - extends Node - func _ready(): - print("Hello, World!") - get_tree().quit() - EOF - - cat >export_presets.cfg <<'EOF' - [preset.0] - name="build" - platform="Linux" - runnable=true - export_filter="all_resources" - include_filter="" - exclude_filter="" - [preset.0.options] - __empty="" - EOF - - runHook postUnpack - ''; - - buildPhase = '' - runHook preBuild - - export HOME=$(mktemp -d) - mkdir -p $HOME/.local/share/godot/export_templates - ln -s "${pkg.export-templates-bin}" "$HOME/.local/share/godot/export_templates/${dottedVersion}" - - godot --headless -s create-scene.gd - - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - - mkdir -p "$out"/bin - godot --headless --export-release build "$out"/bin/test - - runHook postInstall - ''; - }; - in - { - version = testers.testVersion { - package = pkg; - version = dottedVersion; - }; - - project-runs = runCommand "${pkg.name}-project-runs" { } '' - ( - set -eo pipefail - HOME=$(mktemp -d) - "${exportedProject}"/bin/test --headless | tail -n1 | ( - read output - if [[ "$output" != "Hello, World!" ]]; then - echo "unexpected output: $output" >&2 - exit 1 - fi - ) - touch "$out" - ) - ''; - }; - }; - - requiredSystemFeatures = [ - # fixes: No space left on device - "big-parallel" - ]; - - meta = { - changelog = "https://github.com/godotengine/godot/releases/tag/${version}"; - description = "Free and Open Source 2D and 3D game engine"; - homepage = "https://godotengine.org"; - license = lib.licenses.mit; - platforms = [ - "x86_64-linux" - "aarch64-linux" - ] ++ lib.optional (!withMono) "i686-linux"; - maintainers = with lib.maintainers; [ - shiryel - corngood - ]; - mainProgram = "godot4${suffix}"; - }; - }; - -in -stdenv.mkDerivation ( - if withMono then - dotnetCorePackages.addNuGetDeps { - inherit nugetDeps; - overrideFetchAttrs = old: rec { - runtimeIds = map (system: dotnetCorePackages.systemToDotnetRid system) old.meta.platforms; - buildInputs = - old.buildInputs - ++ lib.concatLists (lib.attrValues (lib.getAttrs runtimeIds dotnet-sdk.targetPackages)); + src = fetchFromGitHub { + owner = "godotengine"; + repo = "godot"; + tag = version; + inherit hash; + # Required for the commit hash to be included in the version number. + # + # `methods.py` reads the commit hash from `.git/HEAD` and manually follows + # refs. + # + # See also 'hash' in + # https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info + leaveDotGit = true; + # Only keep HEAD, because leaveDotGit is non-deterministic: + # https://github.com/NixOS/nixpkgs/issues/8567 + postFetch = '' + hash=$(git -C "$out" rev-parse HEAD) + rm -r "$out"/.git + mkdir "$out"/.git + echo "$hash" > "$out"/.git/HEAD + ''; }; - } attrs - else - attrs -) + + outputs = [ + "out" + ] ++ lib.optional (editor) "man"; + separateDebugInfo = true; + + # Set the build name which is part of the version. In official downloads, this + # is set to 'official'. When not specified explicitly, it is set to + # 'custom_build'. Other platforms packaging Godot (Gentoo, Arch, Flatpack + # etc.) usually set this to their name as well. + # + # See also 'methods.py' in the Godot repo and 'build' in + # https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info + BUILD_NAME = "nixpkgs"; + + preConfigure = lib.optionalString withMono '' + # TODO: avoid pulling in dependencies of windows-only project + dotnet sln modules/mono/editor/GodotTools/GodotTools.sln \ + remove modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj + + dotnet restore modules/mono/glue/GodotSharp/GodotSharp.sln + dotnet restore modules/mono/editor/GodotTools/GodotTools.sln + dotnet restore modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln + ''; + + # From: https://github.com/godotengine/godot/blob/4.2.2-stable/SConstruct + sconsFlags = mkSconsFlagsFromAttrSet { + # Options from 'SConstruct' + precision = withPrecision; # Floating-point precision level + production = true; # Set defaults to build Godot for use in production + platform = withPlatform; + inherit target; + debug_symbols = true; + + # Options from 'platform/linuxbsd/detect.py' + alsa = withAlsa; + dbus = withDbus; # Use D-Bus to handle screensaver and portal desktop settings + fontconfig = withFontconfig; # Use fontconfig for system fonts support + pulseaudio = withPulseaudio; # Use PulseAudio + speechd = withSpeechd; # Use Speech Dispatcher for Text-to-Speech support + touch = withTouch; # Enable touch events + udev = withUdev; # Use udev for gamepad connection callbacks + wayland = withWayland; # Compile with Wayland support + x11 = withX11; # Compile with X11 support + + module_mono_enabled = withMono; + + # aliasing bugs exist with hardening+LTO + # https://github.com/godotengine/godot/pull/104501 + ccflags = "-fno-strict-aliasing"; + linkflags = "-Wl,--build-id"; + + use_sowrap = false; + }; + + enableParallelBuilding = true; + + strictDeps = true; + + patches = lib.optionals (lib.versionOlder version "4.4") [ + (fetchpatch { + name = "wayland-header-fix.patch"; + url = "https://github.com/godotengine/godot/commit/6ce71f0fb0a091cffb6adb4af8ab3f716ad8930b.patch"; + hash = "sha256-hgAtAtCghF5InyGLdE9M+9PjPS1BWXWGKgIAyeuqkoU="; + }) + # Fix a crash in the mono test project build. It no longer seems to + # happen in 4.4, but an existing fix couldn't be identified. + ./CSharpLanguage-fix-crash-in-reload_assemblies-after-.patch + ]; + + postPatch = '' + # this stops scons from hiding e.g. NIX_CFLAGS_COMPILE + perl -pi -e '{ $r += s:(env = Environment\(.*):\1\nenv["ENV"] = os.environ: } END { exit ($r != 1) }' SConstruct + + substituteInPlace thirdparty/glad/egl.c \ + --replace-fail \ + 'static const char *NAMES[] = {"libEGL.so.1", "libEGL.so"}' \ + 'static const char *NAMES[] = {"${lib.getLib libGL}/lib/libEGL.so"}' + + substituteInPlace thirdparty/glad/gl.c \ + --replace-fail \ + 'static const char *NAMES[] = {"libGLESv2.so.2", "libGLESv2.so"}' \ + 'static const char *NAMES[] = {"${lib.getLib libGL}/lib/libGLESv2.so"}' \ + + substituteInPlace thirdparty/glad/gl{,x}.c \ + --replace-fail \ + '"libGL.so.1"' \ + '"${lib.getLib libGL}/lib/libGL.so"' + + substituteInPlace thirdparty/volk/volk.c \ + --replace-fail \ + 'dlopen("libvulkan.so.1"' \ + 'dlopen("${lib.getLib vulkan-loader}/lib/libvulkan.so"' + ''; + + depsBuildBuild = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + buildPackages.stdenv.cc + pkg-config + ]; + + buildInputs = + lib.optionals withMono dotnet-sdk.packages + ++ lib.optional withAlsa alsa-lib + ++ lib.optional (withX11 || withWayland) libxkbcommon + ++ lib.optionals withX11 [ + libX11 + libXcursor + libXext + libXfixes + libXi + libXinerama + libXrandr + libXrender + ] + ++ lib.optionals withWayland [ + # libdecor + wayland + ] + ++ lib.optionals withDbus [ + dbus + ] + ++ lib.optionals withFontconfig [ + fontconfig + ] + ++ lib.optional withPulseaudio libpulseaudio + ++ lib.optionals withSpeechd [ + speechd-minimal + glib + ] + ++ lib.optional withUdev udev; + + nativeBuildInputs = + [ + installShellFiles + perl + pkg-config + scons + ] + ++ lib.optionals withWayland [ wayland-scanner ] + ++ lib.optionals withMono [ + dotnet-sdk + makeWrapper + ]; + + postBuild = lib.optionalString (editor && withMono) '' + echo "Generating Glue" + bin/${binary} --headless --generate-mono-glue modules/mono/glue + echo "Building C#/.NET Assemblies" + python modules/mono/build_scripts/build_assemblies.py --godot-output-dir bin --precision=${withPrecision} + ''; + + installPhase = + '' + runHook preInstall + + mkdir -p "$out"/{bin,libexec} + cp -r bin/* "$out"/libexec + + cd "$out"/bin + ln -s ../libexec/${binary} godot${lib.versions.majorMinor version}${suffix} + ln -s godot${lib.versions.majorMinor version}${suffix} godot${lib.versions.major version}${suffix} + ln -s godot${lib.versions.major version}${suffix} godot${suffix} + cd - + '' + + ( + if editor then + '' + installManPage misc/dist/linux/godot.6 + + mkdir -p "$out"/share/{applications,icons/hicolor/scalable/apps} + cp misc/dist/linux/org.godotengine.Godot.desktop "$out/share/applications/org.godotengine.Godot${lib.versions.majorMinor version}${suffix}.desktop" + substituteInPlace "$out/share/applications/org.godotengine.Godot${lib.versions.majorMinor version}${suffix}.desktop" \ + --replace "Exec=godot" "Exec=$out/bin/godot${suffix}" \ + --replace "Godot Engine" "Godot Engine ${ + lib.versions.majorMinor version + lib.optionalString withMono " (Mono)" + }" + cp icon.svg "$out/share/icons/hicolor/scalable/apps/godot.svg" + cp icon.png "$out/share/icons/godot.png" + '' + + lib.optionalString withMono '' + mkdir -p "$out"/share/nuget + mv "$out"/libexec/GodotSharp/Tools/nupkgs "$out"/share/nuget/source + + wrapProgram $out/libexec/${binary} \ + --set DOTNET_ROOT ${dotnet-sdk}/share/dotnet \ + --prefix PATH : "${ + lib.makeBinPath [ + dotnet-sdk + ] + }" + '' + else + let + template = + (lib.replaceStrings + [ "template" ] + [ + { + linuxbsd = "linux"; + } + .${withPlatform} + ] + target + ) + + "." + + arch; + in + '' + templates="$out"/share/godot/export_templates/${dottedVersion} + mkdir -p "$templates" + ln -s "$out"/libexec/${binary} "$templates"/${template} + '' + ) + + '' + runHook postInstall + ''; + + passthru = + { + inherit updateScript; + + tests = + { + version = testers.testVersion { + package = finalAttrs.finalPackage; + version = dottedVersion; + }; + } + // lib.optionalAttrs (editor) ( + let + pkg = finalAttrs.finalPackage; + + project-src = runCommand "${pkg.name}-project-src" { } ( + '' + mkdir "$out" + cd "$out" + touch project.godot + + cat >create-scene.gd <<'EOF' + extends SceneTree + + func _initialize(): + var node = Node.new() + var script = ResourceLoader.load("res://test.gd") + node.set_script(script) + '' + + lib.optionalString withMono '' + ${""} + var monoNode = Node.new() + var monoScript = ResourceLoader.load("res://Test.cs") + monoNode.set_script(monoScript) + node.add_child(monoNode) + monoNode.owner = node + '' + + '' + var scene = PackedScene.new() + var scenePath = "res://test.tscn" + scene.pack(node) + node.free() + var x = ResourceSaver.save(scene, scenePath) + ProjectSettings["application/run/main_scene"] = scenePath + ProjectSettings.save() + quit() + EOF + + cat >test.gd <<'EOF' + extends Node + func _ready(): + print("Hello, World!") + get_tree().quit() + EOF + + cat >export_presets.cfg <<'EOF' + [preset.0] + name="build" + platform="Linux" + runnable=true + export_filter="all_resources" + include_filter="" + exclude_filter="" + [preset.0.options] + binary_format/architecture="${arch}" + EOF + '' + + lib.optionalString withMono '' + cat >Test.cs <<'EOF' + using Godot; + using System; + + public partial class Test : Node + { + public override void _Ready() + { + GD.Print("Hello, Mono!"); + GetTree().Quit(); + } + } + EOF + + sdk_version=$(basename ${pkg}/share/nuget/packages/godot.net.sdk/*) + cat >UnnamedProject.csproj < + + net8.0 + true + + + EOF + '' + ); + + export-tests = lib.makeExtensible (final: { + inherit (pkg) export-template; + + export = stdenvNoCC.mkDerivation { + name = "${final.export-template.name}-export"; + + nativeBuildInputs = [ + pkg + ] ++ lib.optional withMono dotnet-sdk; + + src = project-src; + + postConfigure = lib.optionalString withMono '' + dotnet new sln -n UnnamedProject + message=$(dotnet sln add UnnamedProject.csproj) + echo "$message" + # dotnet sln doesn't return an error when it fails to add the project + [[ $message == "Project \`UnnamedProject.csproj\` added to the solution." ]] + ''; + + exportTemplate = pkg.export-template; + + buildPhase = '' + runHook preBuild + + export HOME=$(mktemp -d) + mkdir -p $HOME/.local/share/godot/ + ln -s "${final.export-template}"/share/godot/export_templates "$HOME"/.local/share/godot/ + + godot${suffix} --headless --build-solutions -s create-scene.gd + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p "$out"/bin + godot${suffix} --headless --export-release build "$out"/bin/test + + runHook postInstall + ''; + }; + + run = runCommand "${final.export.name}-runs" { passthru = { inherit (final) export; }; } ( + '' + ( + set -eo pipefail + HOME=$(mktemp -d) + "${final.export}"/bin/test --headless | tail -n+3 | ( + '' + + lib.optionalString withMono '' + # indent + read output + if [[ "$output" != "Hello, Mono!" ]]; then + echo "unexpected output: $output" >&2 + exit 1 + fi + '' + + '' + read output + if [[ "$output" != "Hello, World!" ]]; then + echo "unexpected output: $output" >&2 + exit 1 + fi + ) + touch "$out" + ) + '' + ); + }); + + in + { + export-runs = export-tests.run; + + export-bin-runs = + (export-tests.extend ( + final: prev: { + export-template = pkg.export-templates-bin; + + export = prev.export.overrideAttrs (prev: { + nativeBuildInputs = prev.nativeBuildInputs or [ ] ++ [ + autoPatchelfHook + ]; + + # stripping dlls results in: + # Failed to load System.Private.CoreLib.dll (error code 0x8007000B) + stripExclude = lib.optional withMono [ "*.dll" ]; + + runtimeDependencies = + prev.runtimeDependencies or [ ] + ++ map lib.getLib [ + alsa-lib + libpulseaudio + libX11 + libXcursor + libXext + libXi + libXrandr + udev + vulkan-loader + ]; + }); + } + )).run; + } + ); + } + // lib.optionalAttrs editor { + export-template = mkTarget "template_release"; + export-templates-bin = ( + callPackage ./export-templates-bin.nix { + inherit version withMono; + godot = finalAttrs.finalPackage; + hash = exportTemplatesHash; + } + ); + }; + + requiredSystemFeatures = [ + # fixes: No space left on device + "big-parallel" + ]; + + meta = { + changelog = "https://github.com/godotengine/godot/releases/tag/${version}"; + description = "Free and Open Source 2D and 3D game engine"; + homepage = "https://godotengine.org"; + license = lib.licenses.mit; + platforms = [ + "x86_64-linux" + "aarch64-linux" + ] ++ lib.optional (!withMono) "i686-linux"; + maintainers = with lib.maintainers; [ + shiryel + corngood + ]; + mainProgram = "godot${suffix}"; + }; + }; + + mkTarget = + target: + let + attrs = attrsForTarget target; + in + stdenv.mkDerivation ( + if withMono then + dotnetCorePackages.addNuGetDeps { + inherit nugetDeps; + overrideFetchAttrs = old: rec { + runtimeIds = map (system: dotnetCorePackages.systemToDotnetRid system) old.meta.platforms; + buildInputs = + old.buildInputs + ++ lib.concatLists (lib.attrValues (lib.getAttrs runtimeIds dotnet-sdk.targetPackages)); + }; + } attrs + else + attrs + ); +in +mkTarget "editor" diff --git a/pkgs/development/tools/godot/default.nix b/pkgs/development/tools/godot/default.nix index d434e29bc4ab..3a935efab866 100644 --- a/pkgs/development/tools/godot/default.nix +++ b/pkgs/development/tools/godot/default.nix @@ -1,5 +1,9 @@ +# TODO: +# - combine binary and source tests +# - filter builtInputs by builtin_ flags { callPackage, + lib, nix-update-script, fetchzip, }: @@ -8,43 +12,40 @@ let versionPrefix: let attrs = import (./. + "/${versionPrefix}/default.nix"); - inherit (attrs) - version - hash - exportTemplatesHash - nugetDeps - ; + updateScript = [ + ./update.sh + versionPrefix + (builtins.unsafeGetAttrPos "version" attrs).file + ]; in - rec { - godot = (callPackage ./common.nix { inherit version hash nugetDeps; }).overrideAttrs (old: { - passthru = old.passthru or { } // { - inherit export-templates-bin; - updateScript = [ - ./update.sh - versionPrefix - (builtins.unsafeGetAttrPos "version" attrs).file - ]; - }; - }); + lib.recurseIntoAttrs rec { + godot = callPackage ./common.nix { + inherit updateScript; + inherit (attrs) + version + hash + ; + inherit (attrs.default) + exportTemplatesHash + ; + }; godot-mono = godot.override { withMono = true; + inherit (attrs.mono) + exportTemplatesHash + nugetDeps + ; }; - export-templates-bin = ( - callPackage ./export-templates-bin.nix { - inherit version godot; - hash = exportTemplatesHash; - } - ); - }; + export-template = godot.export-template; + export-template-mono = godot-mono.export-template; - godotPackages_4_3 = mkGodotPackages "4.3"; - godotPackages_4_4 = mkGodotPackages "4.4"; - godotPackages_4 = godotPackages_4_4; - godotPackages = godotPackages_4; + export-templates-bin = godot.export-templates-bin; + export-templates-mono-bin = godot-mono.export-templates-bin; + }; in -{ +rec { godot3 = callPackage ./3 { }; godot3-export-templates = callPackage ./3/export-templates.nix { }; godot3-headless = callPackage ./3/headless.nix { }; @@ -56,16 +57,21 @@ in godot3-mono-debug-server = callPackage ./3/mono/debug-server.nix { }; godot3-mono-server = callPackage ./3/mono/server.nix { }; + godotPackages_4_3 = mkGodotPackages "4.3"; + godotPackages_4_4 = mkGodotPackages "4.4"; + godotPackages_4 = godotPackages_4_4; + godotPackages = godotPackages_4; + godot_4_3 = godotPackages_4_3.godot; godot_4_3-mono = godotPackages_4_3.godot-mono; - godot_4_3-export-templates = godotPackages_4_3.export-templates-bin; + godot_4_3-export-templates-bin = godotPackages_4_3.export-templates-bin; godot_4_4 = godotPackages_4_4.godot; godot_4_4-mono = godotPackages_4_4.godot-mono; - godot_4_4-export-templates = godotPackages_4_4.export-templates-bin; + godot_4_4-export-templates-bin = godotPackages_4_4.export-templates-bin; godot_4 = godotPackages_4.godot; godot_4-mono = godotPackages_4.godot-mono; - godot_4-export-templates = godotPackages_4.export-templates-bin; + godot_4-export-templates-bin = godotPackages_4.export-templates-bin; godot = godotPackages.godot; godot-mono = godotPackages.godot-mono; - godot-export-templates = godotPackages.export-templates-bin; + godot-export-templates-bin = godotPackages.export-templates-bin; } diff --git a/pkgs/development/tools/godot/export-templates-bin.nix b/pkgs/development/tools/godot/export-templates-bin.nix index 5bec3547041a..829b898b80be 100644 --- a/pkgs/development/tools/godot/export-templates-bin.nix +++ b/pkgs/development/tools/godot/export-templates-bin.nix @@ -1,29 +1,57 @@ { - fetchzip, + fetchurl, godot, hash, lib, + stdenvNoCC, + unzip, version, + withMono ? false, }: # Export templates is necessary for setting up Godot engine, it's used when exporting projects. # Godot applications/games packages needs to reference export templates. # Export templates version should be kept in sync with Godot version. # https://docs.godotengine.org/en/stable/tutorials/export/exporting_projects.html#export-templates -fetchzip { - pname = "godot-export-templates"; - version = version; - extension = "zip"; - url = "https://github.com/godotengine/godot/releases/download/${version}/Godot_v${version}_export_templates.tpz"; - inherit hash; +let + self = stdenvNoCC.mkDerivation { + pname = "godot-export-templates${lib.optionalString withMono "-mono"}-bin"; + version = version; - meta = { - inherit (godot.meta) - changelog - description - homepage - license - maintainers - ; - sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; + src = fetchurl { + url = "https://github.com/godotengine/godot/releases/download/${version}/Godot_v${version}${lib.optionalString withMono "_mono"}_export_templates.tpz"; + inherit hash; + }; + + nativeBuildInputs = [ + unzip + ]; + + unpackPhase = '' + runHook preUnpack + unzip -q "$src" + runHook postUnpack + ''; + + installPhase = '' + templates="$out"/share/godot/export_templates + mkdir -p "$templates" + read version < templates/version.txt + mv templates "$templates/$version" + ''; + + # this allows update-source-version to work + passthru.src = self; + + meta = { + inherit (godot.meta) + changelog + description + homepage + license + maintainers + ; + sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; + }; }; -} +in +self diff --git a/pkgs/development/tools/godot/update.sh b/pkgs/development/tools/godot/update.sh index 25d396e78119..1cf654b70d87 100755 --- a/pkgs/development/tools/godot/update.sh +++ b/pkgs/development/tools/godot/update.sh @@ -1,18 +1,20 @@ #!/usr/bin/env nix-shell -#!nix-shell -I nixpkgs=./. --pure -i bash -p bash nix nix-update git cacert common-updater-scripts --keep UPDATE_NIX_ATTR_PATH --keep UPDATE_NIX_OLD_VERSION +#!nix-shell -I nixpkgs=./. --pure -i bash -p bash nix nix-update git cacert common-updater-scripts set -euo pipefail versionPrefix=$1 file=$2 -attr=$UPDATE_NIX_ATTR_PATH +attr=godotPackages_${versionPrefix/./_} -prev_version=$UPDATE_NIX_OLD_VERSION -nix-update "$attr" \ +prev_version=$(nix eval --raw -f. "$attr".godot) +nix-update "$attr".godot \ --version-regex "($versionPrefix\\b.*-stable)" \ --override-filename "$2" \ --src-only -[[ $(nix eval --raw -f. "$attr".version) != "$prev_version" ]] || exit 0 +[[ $(nix eval --raw -f. "$attr".godot) != "$prev_version" ]] || exit 0 -"$(nix build --impure --expr "((import ./. {}).$attr.override { withMono = true; }).fetch-deps" --print-out-paths --no-link)" +fetch_deps=$(nix build -f. "$attr".godot-mono.fetch-deps --print-out-paths --no-link) +"$fetch_deps" -update-source-version "$attr" --ignore-same-version --source-key=export-templates-bin --file="$file" +update-source-version "$attr".godot.export-templates-bin --ignore-same-version --file="$file" +update-source-version "$attr".godot-mono.export-templates-bin --ignore-same-version --file="$file" diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index dea572985f7d..6f6dbc1d17dd 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -796,6 +796,10 @@ mapAliases { grafana-agent = throw "'grafana-agent' has been removed, as it only works with an EOL compiler and will become EOL during the 25.05 release. Consider migrating to 'grafana-alloy' instead"; # Added 2025-04-02 #godot + godot_4_3-export-templates = lib.warnOnInstantiate "godot_4_3-export-templates has been renamed to godot_4_3-export-templates-bin" godot_4_3-export-templates-bin; + godot_4_4-export-templates = lib.warnOnInstantiate "godot_4_4-export-templates has been renamed to godot_4_4-export-templates-bin" godot_4_4-export-templates-bin; + godot_4-export-templates = lib.warnOnInstantiate "godot_4-export-templates has been renamed to godot_4-export-templates-bin" godot_4-export-templates-bin; + godot-export-templates = lib.warnOnInstantiate "godot-export-templates has been renamed to godot-export-templates-bin" godot-export-templates-bin; go-thumbnailer = thud; # Added 2023-09-21 go-upower-notify = upower-notify; # Added 2024-07-21 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3e80b0e5c643..65aab8b5c4a0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3158,18 +3158,22 @@ with pkgs; godot3-mono-headless godot3-mono-debug-server godot3-mono-server + godotPackages_4_3 + godotPackages_4_4 + godotPackages_4 + godotPackages godot_4_3 godot_4_3-mono - godot_4_3-export-templates + godot_4_3-export-templates-bin godot_4_4 godot_4_4-mono - godot_4_4-export-templates + godot_4_4-export-templates-bin godot_4 godot_4-mono - godot_4-export-templates + godot_4-export-templates-bin godot godot-mono - godot-export-templates + godot-export-templates-bin ; goattracker = callPackage ../applications/audio/goattracker { };