26 , withPlatform ? "linuxbsd"
27 , withTarget ? "editor"
28 , withPrecision ? "single"
29 , withPulseaudio ? true
32 , withFontconfig ? true
37 assert lib.asserts.assertOneOf "withPrecision" withPrecision [ "single" "double" ];
40 mkSconsFlagsFromAttrSet = lib.mapAttrsToList (k: v:
41 if builtins.isString v
43 else "${k}=${builtins.toJSON v}");
45 stdenv.mkDerivation rec {
47 version = "4.2.2-stable";
48 commitHash = "15073afe3856abd2aa1622492fe50026c7d63dc1";
50 src = fetchFromGitHub {
51 owner = "godotengine";
54 hash = "sha256-anJgPEeHIW2qIALMfPduBVgbYYyz1PWCmPsZZxS9oHI=";
67 runtimeDependencies = [
81 ++ lib.optional withPulseaudio libpulseaudio
82 ++ lib.optional withDbus dbus
83 ++ lib.optional withDbus dbus.lib
84 ++ lib.optional withSpeechd speechd
85 ++ lib.optional withFontconfig fontconfig
86 ++ lib.optional withFontconfig fontconfig.lib
87 ++ lib.optional withUdev udev;
89 enableParallelBuilding = true;
91 # Set the build name which is part of the version. In official downloads, this
92 # is set to 'official'. When not specified explicitly, it is set to
93 # 'custom_build'. Other platforms packaging Godot (Gentoo, Arch, Flatpack
94 # etc.) usually set this to their name as well.
96 # See also 'methods.py' in the Godot repo and 'build' in
97 # https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info
98 BUILD_NAME = "nixpkgs";
100 # Required for the commit hash to be included in the version number.
102 # `methods.py` reads the commit hash from `.git/HEAD` and manually follows
103 # refs. Since we just write the hash directly, there is no need to emulate any
104 # other parts of the .git directory.
107 # https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info
110 echo ${commitHash} > .git/HEAD
113 sconsFlags = mkSconsFlagsFromAttrSet {
114 # Options from 'SConstruct'
115 production = true; # Set defaults to build Godot for use in production
116 platform = withPlatform;
118 precision = withPrecision; # Floating-point precision level
119 debug_symbols = withDebug;
121 # Options from 'platform/linuxbsd/detect.py'
122 pulseaudio = withPulseaudio; # Use PulseAudio
123 dbus = withDbus; # Use D-Bus to handle screensaver and portal desktop settings
124 speechd = withSpeechd; # Use Speech Dispatcher for Text-to-Speech support
125 fontconfig = withFontconfig; # Use fontconfig for system fonts support
126 udev = withUdev; # Use udev for gamepad connection callbacks
127 touch = withTouch; # Enable touch events
130 dontStrip = withDebug;
132 outputs = [ "out" "man" ];
136 cp bin/godot.* $out/bin/godot4
138 installManPage misc/dist/linux/godot.6
140 mkdir -p "$out"/share/{applications,icons/hicolor/scalable/apps}
141 cp misc/dist/linux/org.godotengine.Godot.desktop "$out/share/applications/org.godotengine.Godot4.desktop"
142 substituteInPlace "$out/share/applications/org.godotengine.Godot4.desktop" \
143 --replace "Exec=godot" "Exec=$out/bin/godot4" \
144 --replace "Godot Engine" "Godot Engine 4"
145 cp icon.svg "$out/share/icons/hicolor/scalable/apps/godot.svg"
146 cp icon.png "$out/share/icons/godot.png"
150 homepage = "https://godotengine.org";
151 description = "Free and Open Source 2D and 3D game engine";
152 license = lib.licenses.mit;
153 platforms = [ "i686-linux" "x86_64-linux" "aarch64-linux" ];
154 maintainers = with lib.maintainers; [ shiryel superherointj ];
155 mainProgram = "godot4";