From 27afb70cd2d8b41146309bb958045369c9b027c8 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 10 Mar 2025 21:13:59 -0300 Subject: [PATCH 01/11] godot: fix runHook typo --- pkgs/development/tools/godot/common.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/tools/godot/common.nix b/pkgs/development/tools/godot/common.nix index bab845d6af5d..17c624b59e23 100644 --- a/pkgs/development/tools/godot/common.nix +++ b/pkgs/development/tools/godot/common.nix @@ -238,7 +238,7 @@ let '' + '' ln -s godot4${suffix} "$out"/bin/godot - runHook post Install + runHook postInstall ''; # patching $debug can crash patchelf From da9f85d9cc7cc20168ec80afa3aca9da8bbe35ae Mon Sep 17 00:00:00 2001 From: David McFarland Date: Tue, 25 Mar 2025 15:02:25 -0300 Subject: [PATCH 02/11] godot-mono: fix DOTNET_ROOT --- pkgs/development/tools/godot/common.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/tools/godot/common.nix b/pkgs/development/tools/godot/common.nix index 17c624b59e23..4304ed3b8c06 100644 --- a/pkgs/development/tools/godot/common.nix +++ b/pkgs/development/tools/godot/common.nix @@ -229,7 +229,7 @@ let + lib.optionalString withMono '' cp -r bin/GodotSharp/ $out/bin/ wrapProgram $out/bin/godot4${suffix} \ - --set DOTNET_ROOT ${dotnet-sdk} \ + --set DOTNET_ROOT ${dotnet-sdk}/share/dotnet \ --prefix PATH : "${ lib.makeBinPath [ dotnet-sdk From 03756b98364a8e8c4319d1a5b163d25a5b297fe5 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Thu, 27 Mar 2025 13:25:30 -0300 Subject: [PATCH 03/11] godot: move export templates into share/godot/export_templates --- doc/release-notes/rl-2505.section.md | 2 ++ pkgs/by-name/op/opengamepadui/package.nix | 6 ++-- pkgs/by-name/pi/pixelorama/package.nix | 4 +-- pkgs/development/tools/godot/4.3/default.nix | 2 +- pkgs/development/tools/godot/4.4/default.nix | 2 +- pkgs/development/tools/godot/common.nix | 4 +-- .../tools/godot/export-templates-bin.nix | 31 ++++++++++++++++--- 7 files changed, 37 insertions(+), 14 deletions(-) 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..987c84ca11a4 100644 --- a/pkgs/by-name/op/opengamepadui/package.nix +++ b/pkgs/by-name/op/opengamepadui/package.nix @@ -81,7 +81,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-templates-bin}/share/godot/export_templates"; BUILD_TYPE = "${finalAttrs.buildType}"; }; @@ -92,8 +92,8 @@ 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 = '' diff --git a/pkgs/by-name/pi/pixelorama/package.nix b/pkgs/by-name/pi/pixelorama/package.nix index 5443e94a527d..d6668a78ed3f 100644 --- a/pkgs/by-name/pi/pixelorama/package.nix +++ b/pkgs/by-name/pi/pixelorama/package.nix @@ -65,8 +65,8 @@ stdenv.mkDerivation (finalAttrs: { 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-templates-bin}"/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..31c5bebd3869 100644 --- a/pkgs/development/tools/godot/4.3/default.nix +++ b/pkgs/development/tools/godot/4.3/default.nix @@ -1,6 +1,6 @@ { version = "4.3-stable"; hash = "sha256-MzElflwXHWLgPtoOIhPLA00xX8eEdQsexZaGIEOzbj0="; - exportTemplatesHash = "sha256-XRnKii+eexIkbGf7bqc42SR0NBULFvgMdOpSRNNk6kg="; + exportTemplatesHash = "sha256-9fENuvVqeQg0nmS5TqjCyTwswR+xAUyVZbaKK7Q3uSI="; 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..0d67aacff6c2 100644 --- a/pkgs/development/tools/godot/4.4/default.nix +++ b/pkgs/development/tools/godot/4.4/default.nix @@ -1,6 +1,6 @@ { version = "4.4.1-stable"; hash = "sha256-O4TdPYu1K2zWKMBP/7xd0UPLDb7/4dBnkGM7QydD3Yo="; - exportTemplatesHash = "sha256-KV4sDBZPiMf7IORaNFR2uEK1midnyyjCUfG9hl6AwHY="; + exportTemplatesHash = "sha256-eo0UreSJ/U0i8XgZMCH+iodqnlEGjtTd4m2sOuTFmog="; nugetDeps = ./deps.json; } diff --git a/pkgs/development/tools/godot/common.nix b/pkgs/development/tools/godot/common.nix index 4304ed3b8c06..0ab7725d9ca5 100644 --- a/pkgs/development/tools/godot/common.nix +++ b/pkgs/development/tools/godot/common.nix @@ -326,8 +326,8 @@ let 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}" + mkdir -p $HOME/.local/share/godot/ + ln -s "${pkg.export-templates-bin}"/share/godot/export_templates "$HOME"/.local/share/godot/ godot --headless -s create-scene.gd diff --git a/pkgs/development/tools/godot/export-templates-bin.nix b/pkgs/development/tools/godot/export-templates-bin.nix index 5bec3547041a..b1a15b95c77e 100644 --- a/pkgs/development/tools/godot/export-templates-bin.nix +++ b/pkgs/development/tools/godot/export-templates-bin.nix @@ -1,20 +1,41 @@ { - fetchzip, + fetchurl, godot, hash, lib, + stdenvNoCC, + unzip, version, }: # 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 { +stdenvNoCC.mkDerivation { 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; + + src = fetchurl { + url = "https://github.com/godotengine/godot/releases/download/${version}/Godot_v${version}_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" + ''; meta = { inherit (godot.meta) From 312201aeb32153ab1d498927190df6ffb8103f65 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Thu, 27 Mar 2025 13:39:14 -0300 Subject: [PATCH 04/11] godot-export-templates: rename to godot-export-templates-bin --- pkgs/development/tools/godot/default.nix | 8 ++++---- pkgs/development/tools/godot/export-templates-bin.nix | 2 +- pkgs/top-level/aliases.nix | 4 ++++ pkgs/top-level/all-packages.nix | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pkgs/development/tools/godot/default.nix b/pkgs/development/tools/godot/default.nix index d434e29bc4ab..4b56e5d3df5b 100644 --- a/pkgs/development/tools/godot/default.nix +++ b/pkgs/development/tools/godot/default.nix @@ -58,14 +58,14 @@ in 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 b1a15b95c77e..cffba33de190 100644 --- a/pkgs/development/tools/godot/export-templates-bin.nix +++ b/pkgs/development/tools/godot/export-templates-bin.nix @@ -12,7 +12,7 @@ # Export templates version should be kept in sync with Godot version. # https://docs.godotengine.org/en/stable/tutorials/export/exporting_projects.html#export-templates stdenvNoCC.mkDerivation { - pname = "godot-export-templates"; + pname = "godot-export-templates-bin"; version = version; src = fetchurl { 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 ad1bacc7f5e4..24ed1b7af1be 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3166,16 +3166,16 @@ with pkgs; godot3-mono-server 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 { }; From 54fee419c538572aa12bd4ec80088f49f8b7b440 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 10 Mar 2025 01:43:30 -0300 Subject: [PATCH 05/11] godot: package export templates --- pkgs/development/tools/godot/4.3/default.nix | 9 +- pkgs/development/tools/godot/4.4/default.nix | 9 +- ...ix-crash-in-reload_assemblies-after-.patch | 30 + pkgs/development/tools/godot/common.nix | 833 +++++++++++------- pkgs/development/tools/godot/default.nix | 64 +- .../tools/godot/export-templates-bin.nix | 77 +- pkgs/development/tools/godot/update.sh | 16 +- pkgs/top-level/all-packages.nix | 4 + 8 files changed, 628 insertions(+), 414 deletions(-) create mode 100644 pkgs/development/tools/godot/CSharpLanguage-fix-crash-in-reload_assemblies-after-.patch diff --git a/pkgs/development/tools/godot/4.3/default.nix b/pkgs/development/tools/godot/4.3/default.nix index 31c5bebd3869..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-9fENuvVqeQg0nmS5TqjCyTwswR+xAUyVZbaKK7Q3uSI="; - 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 0d67aacff6c2..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-eo0UreSJ/U0i8XgZMCH+iodqnlEGjtTd4m2sOuTFmog="; - 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 0ab7725d9ca5..8f94d6c61812 100644 --- a/pkgs/development/tools/godot/common.nix +++ b/pkgs/development/tools/godot/common.nix @@ -2,8 +2,10 @@ alsa-lib, autoPatchelfHook, buildPackages, + callPackage, dbus, dotnetCorePackages, + exportTemplatesHash, fetchFromGitHub, fontconfig, hash, @@ -30,6 +32,7 @@ stdenvNoCC, testers, udev, + updateScript, version, vulkan-loader, wayland, @@ -42,7 +45,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 +61,501 @@ 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}/share/dotnet \ - --prefix PATH : "${ - lib.makeBinPath [ - dotnet-sdk - ] - }" - '' - + '' - ln -s godot4${suffix} "$out"/bin/godot - runHook postInstall - ''; - - # 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/ - ln -s "${pkg.export-templates-bin}"/share/godot/export_templates "$HOME"/.local/share/godot/ - - 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' + 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; + + patches = lib.optionals (lib.versionOlder version "4.4") [ + # 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 + ]; + + 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 (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} + ''; + + 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,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 + ''; + + # patching $debug can crash patchelf + # (https://github.com/NixOS/patchelf/issues/373), so explicitly patch $out + dontAutoPatchelf = true; + + postFixup = '' + autoPatchelf "$out" + ''; + + 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] + __empty="" + 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 4b56e5d3df5b..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,6 +57,11 @@ 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-bin = godotPackages_4_3.export-templates-bin; diff --git a/pkgs/development/tools/godot/export-templates-bin.nix b/pkgs/development/tools/godot/export-templates-bin.nix index cffba33de190..829b898b80be 100644 --- a/pkgs/development/tools/godot/export-templates-bin.nix +++ b/pkgs/development/tools/godot/export-templates-bin.nix @@ -6,45 +6,52 @@ 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 -stdenvNoCC.mkDerivation { - pname = "godot-export-templates-bin"; - version = version; +let + self = stdenvNoCC.mkDerivation { + pname = "godot-export-templates${lib.optionalString withMono "-mono"}-bin"; + version = version; - src = fetchurl { - url = "https://github.com/godotengine/godot/releases/download/${version}/Godot_v${version}_export_templates.tpz"; - inherit hash; + 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 ]; + }; }; - - 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" - ''; - - 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/all-packages.nix b/pkgs/top-level/all-packages.nix index 24ed1b7af1be..3e14dcf0aade 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3164,6 +3164,10 @@ 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-bin From 422715dd51198eb00bb975e8211ae4f798d112c9 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 24 Mar 2025 19:16:43 -0300 Subject: [PATCH 06/11] pixelorama: use source-built export template --- pkgs/by-name/pi/pixelorama/package.nix | 28 +------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/pkgs/by-name/pi/pixelorama/package.nix b/pkgs/by-name/pi/pixelorama/package.nix index d6668a78ed3f..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/ - ln -s "${godot.export-templates-bin}"/share/godot/export_templates "$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 From 71d45892c99471a70bb0e24619651e80555eefa9 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 24 Mar 2025 19:19:25 -0300 Subject: [PATCH 07/11] opengamepadui: use source-built export template --- pkgs/by-name/op/opengamepadui/package.nix | 46 +++++++++-------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/pkgs/by-name/op/opengamepadui/package.nix b/pkgs/by-name/op/opengamepadui/package.nix index 987c84ca11a4..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}/share/godot/export_templates"; + EXPORT_TEMPLATE = "${godot_4_4.export-template}/share/godot/export_templates"; BUILD_TYPE = "${finalAttrs.buildType}"; }; @@ -96,11 +73,22 @@ stdenv.mkDerivation (finalAttrs: { 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 { }; From 43c0c570465580f8254a5889e7d498906ef88e92 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 21 Apr 2025 21:32:08 -0300 Subject: [PATCH 08/11] godot: fix compiler environment in scons --- pkgs/development/tools/godot/common.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/development/tools/godot/common.nix b/pkgs/development/tools/godot/common.nix index 8f94d6c61812..6d8d178f3a53 100644 --- a/pkgs/development/tools/godot/common.nix +++ b/pkgs/development/tools/godot/common.nix @@ -24,6 +24,7 @@ libXrandr, libXrender, makeWrapper, + perl, pkg-config, runCommand, scons, @@ -168,6 +169,11 @@ let ./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 + ''; + depsBuildBuild = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ buildPackages.stdenv.cc pkg-config @@ -179,6 +185,7 @@ let [ autoPatchelfHook installShellFiles + perl pkg-config scons ] From 4db0687258093c498e2b913519f46ce14128ab0a Mon Sep 17 00:00:00 2001 From: David McFarland Date: Sun, 9 Mar 2025 20:17:03 -0300 Subject: [PATCH 09/11] godot: disable sowrap --- pkgs/development/tools/godot/common.nix | 104 ++++++++++++++---------- 1 file changed, 61 insertions(+), 43 deletions(-) diff --git a/pkgs/development/tools/godot/common.nix b/pkgs/development/tools/godot/common.nix index 6d8d178f3a53..e2698c7b6df6 100644 --- a/pkgs/development/tools/godot/common.nix +++ b/pkgs/development/tools/godot/common.nix @@ -7,7 +7,9 @@ dotnetCorePackages, exportTemplatesHash, fetchFromGitHub, + fetchpatch, fontconfig, + glib, hash, installShellFiles, lib, @@ -38,6 +40,7 @@ vulkan-loader, wayland, wayland-scanner, + withAlsa ? true, withDbus ? true, withFontconfig ? true, withMono ? false, @@ -145,6 +148,7 @@ let 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 @@ -157,6 +161,8 @@ let module_mono_enabled = withMono; linkflags = "-Wl,--build-id"; + + use_sowrap = false; }; enableParallelBuilding = true; @@ -164,6 +170,11 @@ let 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 @@ -172,6 +183,26 @@ let 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) [ @@ -179,11 +210,39 @@ let pkg-config ]; - buildInputs = lib.optionals withMono dotnet-sdk.packages; + 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 = [ - autoPatchelfHook installShellFiles perl pkg-config @@ -202,39 +261,6 @@ let 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 @@ -301,14 +327,6 @@ let runHook postInstall ''; - # patching $debug can crash patchelf - # (https://github.com/NixOS/patchelf/issues/373), so explicitly patch $out - dontAutoPatchelf = true; - - postFixup = '' - autoPatchelf "$out" - ''; - passthru = { inherit updateScript; From f2ae5385a21f5ea2ee6e913d353b627ae61ded6f Mon Sep 17 00:00:00 2001 From: David McFarland Date: Sun, 23 Mar 2025 00:47:25 -0300 Subject: [PATCH 10/11] godot: disable strict aliasing --- pkgs/development/tools/godot/common.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/tools/godot/common.nix b/pkgs/development/tools/godot/common.nix index e2698c7b6df6..ff75a9620d8b 100644 --- a/pkgs/development/tools/godot/common.nix +++ b/pkgs/development/tools/godot/common.nix @@ -160,6 +160,9 @@ let 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; From 1a8f4e478c98e4394fdf2c92381704618a004020 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Sat, 10 May 2025 20:45:23 -0300 Subject: [PATCH 11/11] fixup! godot: package export templates --- pkgs/development/tools/godot/common.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/tools/godot/common.nix b/pkgs/development/tools/godot/common.nix index ff75a9620d8b..40a4682bfd00 100644 --- a/pkgs/development/tools/godot/common.nix +++ b/pkgs/development/tools/godot/common.nix @@ -394,7 +394,7 @@ let include_filter="" exclude_filter="" [preset.0.options] - __empty="" + binary_format/architecture="${arch}" EOF '' + lib.optionalString withMono ''