evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / go / godot_4 / package.nix
blob64267cd632183997d89074957d1a3a1ebf5437f9
2   alsa-lib,
3   autoPatchelfHook,
4   buildPackages,
5   dbus,
6   dotnet-sdk_8,
7   dotnetCorePackages,
8   fetchFromGitHub,
9   fontconfig,
10   installShellFiles,
11   lib,
12   libdecor,
13   libGL,
14   libpulseaudio,
15   libX11,
16   libXcursor,
17   libXext,
18   libXfixes,
19   libXi,
20   libXinerama,
21   libxkbcommon,
22   libXrandr,
23   libXrender,
24   makeWrapper,
25   pkg-config,
26   scons,
27   speechd-minimal,
28   stdenv,
29   udev,
30   vulkan-loader,
31   wayland,
32   wayland-scanner,
33   withDbus ? true,
34   withFontconfig ? true,
35   withMono ? false,
36   withPlatform ? "linuxbsd",
37   withPrecision ? "single",
38   withPulseaudio ? true,
39   withSpeechd ? true,
40   withTarget ? "editor",
41   withTouch ? true,
42   withUdev ? true,
43   # Wayland in Godot requires X11 until upstream fix is merged
44   # https://github.com/godotengine/godot/pull/73504
45   withWayland ? true,
46   withX11 ? true,
48 assert lib.asserts.assertOneOf "withPrecision" withPrecision [
49   "single"
50   "double"
52 let
53   mkSconsFlagsFromAttrSet = lib.mapAttrsToList (
54     k: v: if builtins.isString v then "${k}=${v}" else "${k}=${builtins.toJSON v}"
55   );
57   suffix = if withMono then "-mono" else "";
59   attrs = rec {
60     pname = "godot4${suffix}";
61     version = "4.3-stable";
62     commitHash = "77dcf97d82cbfe4e4615475fa52ca03da645dbd8";
64     src = fetchFromGitHub {
65       owner = "godotengine";
66       repo = "godot";
67       rev = commitHash;
68       hash = "sha256-v2lBD3GEL8CoIwBl3UoLam0dJxkLGX0oneH6DiWkEsM=";
69     };
71     outputs = [
72       "out"
73       "man"
74     ];
75     separateDebugInfo = true;
77     # Set the build name which is part of the version. In official downloads, this
78     # is set to 'official'. When not specified explicitly, it is set to
79     # 'custom_build'. Other platforms packaging Godot (Gentoo, Arch, Flatpack
80     # etc.) usually set this to their name as well.
81     #
82     # See also 'methods.py' in the Godot repo and 'build' in
83     # https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info
84     BUILD_NAME = "nixpkgs";
86     # Required for the commit hash to be included in the version number.
87     #
88     # `methods.py` reads the commit hash from `.git/HEAD` and manually follows
89     # refs. Since we just write the hash directly, there is no need to emulate any
90     # other parts of the .git directory.
91     #
92     # See also 'hash' in
93     # https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info
94     preConfigure =
95       ''
96         mkdir -p .git
97         echo ${commitHash} > .git/HEAD
98       ''
99       + lib.optionalString withMono ''
100         dotnet restore modules/mono/glue/GodotSharp/GodotSharp.sln
101         dotnet restore modules/mono/editor/GodotTools/GodotTools.sln
102         dotnet restore modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln
103       '';
105     # From: https://github.com/godotengine/godot/blob/4.2.2-stable/SConstruct
106     sconsFlags = mkSconsFlagsFromAttrSet {
107       # Options from 'SConstruct'
108       precision = withPrecision; # Floating-point precision level
109       production = true; # Set defaults to build Godot for use in production
110       platform = withPlatform;
111       target = withTarget;
112       debug_symbols = true;
114       # Options from 'platform/linuxbsd/detect.py'
115       dbus = withDbus; # Use D-Bus to handle screensaver and portal desktop settings
116       fontconfig = withFontconfig; # Use fontconfig for system fonts support
117       pulseaudio = withPulseaudio; # Use PulseAudio
118       speechd = withSpeechd; # Use Speech Dispatcher for Text-to-Speech support
119       touch = withTouch; # Enable touch events
120       udev = withUdev; # Use udev for gamepad connection callbacks
121       wayland = withWayland; # Compile with Wayland support
122       x11 = withX11; # Compile with X11 support
124       module_mono_enabled = withMono;
125     };
127     enableParallelBuilding = true;
129     strictDeps = true;
131     depsBuildBuild = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
132       buildPackages.stdenv.cc
133       pkg-config
134     ];
136     nativeBuildInputs =
137       [
138         autoPatchelfHook
139         installShellFiles
140         pkg-config
141         scons
142       ]
143       ++ lib.optionals withWayland [ wayland-scanner ]
144       ++ lib.optionals withMono [
145         dotnet-sdk_8
146         makeWrapper
147       ];
149     postBuild = lib.optionalString withMono ''
150       echo "Generating Glue"
151       if [[ ${withPrecision} == *double* ]]; then
152           bin/godot.${withPlatform}.${withTarget}.${withPrecision}.x86_64.mono --headless --generate-mono-glue modules/mono/glue
153       else
154           bin/godot.${withPlatform}.${withTarget}.x86_64.mono --headless --generate-mono-glue modules/mono/glue
155       fi
156       echo "Building C#/.NET Assemblies"
157       python modules/mono/build_scripts/build_assemblies.py --godot-output-dir bin --precision=${withPrecision}
158     '';
160     runtimeDependencies =
161       [
162         alsa-lib
163         libGL
164         vulkan-loader
165       ]
166       ++ lib.optionals withX11 [
167         libX11
168         libXcursor
169         libXext
170         libXfixes
171         libXi
172         libXinerama
173         libxkbcommon
174         libXrandr
175         libXrender
176       ]
177       ++ lib.optionals withWayland [
178         libdecor
179         wayland
180       ]
181       ++ lib.optionals withDbus [
182         dbus
183         dbus.lib
184       ]
185       ++ lib.optionals withFontconfig [
186         fontconfig
187         fontconfig.lib
188       ]
189       ++ lib.optionals withPulseaudio [ libpulseaudio ]
190       ++ lib.optionals withSpeechd [ speechd-minimal ]
191       ++ lib.optionals withUdev [ udev ];
193     installPhase =
194       ''
195         runHook preInstall
197         mkdir -p "$out/bin"
198         cp bin/godot.* $out/bin/godot4${suffix}
200         installManPage misc/dist/linux/godot.6
202         mkdir -p "$out"/share/{applications,icons/hicolor/scalable/apps}
203         cp misc/dist/linux/org.godotengine.Godot.desktop "$out/share/applications/org.godotengine.Godot4${suffix}.desktop"
204         substituteInPlace "$out/share/applications/org.godotengine.Godot4${suffix}.desktop" \
205           --replace "Exec=godot" "Exec=$out/bin/godot4${suffix}" \
206           --replace "Godot Engine" "Godot Engine 4"
207         cp icon.svg "$out/share/icons/hicolor/scalable/apps/godot.svg"
208         cp icon.png "$out/share/icons/godot.png"
209       ''
210       + lib.optionalString withMono ''
211         cp -r bin/GodotSharp/ $out/bin/
212         wrapProgram $out/bin/godot4${suffix} \
213           --set DOTNET_ROOT ${dotnet-sdk_8} \
214           --prefix PATH : "${
215             lib.makeBinPath [
216               dotnet-sdk_8
217             ]
218           }"
219       ''
220       + ''
221         runHook postInstall
222       '';
224     meta = {
225       changelog = "https://github.com/godotengine/godot/releases/tag/${version}";
226       description = "Free and Open Source 2D and 3D game engine";
227       homepage = "https://godotengine.org";
228       license = lib.licenses.mit;
229       platforms = [
230         "x86_64-linux"
231         "aarch64-linux"
232       ] ++ lib.optional (!withMono) "i686-linux";
233       maintainers = with lib.maintainers; [
234         shiryel
235         corngood
236       ];
237       mainProgram = "godot4${suffix}";
238     };
239   };
242 stdenv.mkDerivation (
243   finalAttrs:
244   if withMono then
245     dotnetCorePackages.addNuGetDeps {
246       nugetDeps = ./deps.nix;
247       overrideFetchAttrs = old: rec {
248         runtimeIds = map (system: dotnetCorePackages.systemToDotnetRid system) old.meta.platforms;
249         buildInputs =
250           old.buildInputs
251           ++ lib.concatLists (lib.attrValues (lib.getAttrs runtimeIds dotnet-sdk_8.targetPackages));
252       };
253     } attrs finalAttrs
254   else
255     attrs