Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv
2, lib
3, fetchFromGitHub
4, pkg-config
5, autoPatchelfHook
6, installShellFiles
7, scons
8, vulkan-loader
9, libGL
10, libX11
11, libXcursor
12, libXinerama
13, libXext
14, libXrandr
15, libXrender
16, libXi
17, libXfixes
18, libxkbcommon
19, alsa-lib
20, libpulseaudio
21, dbus
22, speechd
23, fontconfig
24, udev
25, withPlatform ? "linuxbsd"
26, withTarget ? "editor"
27, withPrecision ? "single"
28, withPulseaudio ? true
29, withDbus ? true
30, withSpeechd ? true
31, withFontconfig ? true
32, withUdev ? true
33, withTouch ? true
34}:
35
36assert lib.asserts.assertOneOf "withPrecision" withPrecision [ "single" "double" ];
37
38let
39 options = {
40 # Options from 'godot/SConstruct'
41 platform = withPlatform;
42 target = withTarget;
43 precision = withPrecision; # Floating-point precision level
44
45 # Options from 'godot/platform/linuxbsd/detect.py'
46 pulseaudio = withPulseaudio; # Use PulseAudio
47 dbus = withDbus; # Use D-Bus to handle screensaver and portal desktop settings
48 speechd = withSpeechd; # Use Speech Dispatcher for Text-to-Speech support
49 fontconfig = withFontconfig; # Use fontconfig for system fonts support
50 udev = withUdev; # Use udev for gamepad connection callbacks
51 touch = withTouch; # Enable touch events
52 };
53in
54stdenv.mkDerivation rec {
55 pname = "godot";
56 version = "4.0.3-stable";
57
58 src = fetchFromGitHub {
59 owner = "godotengine";
60 repo = "godot";
61 rev = version;
62 hash = "sha256-g9+CV3HsiJqiSJpZvK0N7BqKzp2Pvi6otjRLsFdmWGk=";
63 };
64
65 nativeBuildInputs = [
66 pkg-config
67 autoPatchelfHook
68 installShellFiles
69 ];
70
71 buildInputs = [
72 scons
73 ];
74
75 runtimeDependencies = [
76 vulkan-loader
77 libGL
78 libX11
79 libXcursor
80 libXinerama
81 libXext
82 libXrandr
83 libXrender
84 libXi
85 libXfixes
86 libxkbcommon
87 alsa-lib
88 ]
89 ++ lib.optional withPulseaudio libpulseaudio
90 ++ lib.optional withDbus dbus
91 ++ lib.optional withDbus dbus.lib
92 ++ lib.optional withSpeechd speechd
93 ++ lib.optional withFontconfig fontconfig
94 ++ lib.optional withFontconfig fontconfig.lib
95 ++ lib.optional withUdev udev;
96
97 enableParallelBuilding = true;
98
99 # Options from 'godot/SConstruct' and 'godot/platform/linuxbsd/detect.py'
100 sconsFlags = [ "production=true" ];
101 preConfigure = ''
102 sconsFlags+=" ${
103 lib.concatStringsSep " "
104 (lib.mapAttrsToList (k: v: "${k}=${builtins.toJSON v}") options)
105 }"
106 '';
107
108 outputs = [ "out" "man" ];
109
110 installPhase = ''
111 mkdir -p "$out/bin"
112 cp bin/godot.* $out/bin/godot4
113
114 installManPage misc/dist/linux/godot.6
115
116 mkdir -p "$out"/share/{applications,icons/hicolor/scalable/apps}
117 cp misc/dist/linux/org.godotengine.Godot.desktop "$out/share/applications/org.godotengine.Godot4.desktop"
118 substituteInPlace "$out/share/applications/org.godotengine.Godot4.desktop" \
119 --replace "Exec=godot" "Exec=$out/bin/godot4" \
120 --replace "Godot Engine" "Godot Engine 4"
121 cp icon.svg "$out/share/icons/hicolor/scalable/apps/godot.svg"
122 cp icon.png "$out/share/icons/godot.png"
123 '';
124
125 meta = with lib; {
126 homepage = "https://godotengine.org";
127 description = "Free and Open Source 2D and 3D game engine";
128 license = licenses.mit;
129 platforms = [ "i686-linux" "x86_64-linux" "aarch64-linux" ];
130 maintainers = with maintainers; [ twey shiryel ];
131 };
132}