nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 188 lines 5.1 kB view raw
1{ 2 lib, 3 stdenv, 4 alsa-lib, 5 alsa-plugins, 6 autoPatchelfHook, 7 fetchFromGitHub, 8 freetype, 9 installShellFiles, 10 libGLU, 11 libpulseaudio, 12 libX11, 13 libXcursor, 14 libXext, 15 libXfixes, 16 libXi, 17 libXinerama, 18 libXrandr, 19 libXrender, 20 makeWrapper, 21 openssl, 22 pkg-config, 23 scons, 24 udev, 25 yasm, 26 zlib, 27}: 28 29stdenv.mkDerivation (self: { 30 pname = "godot3"; 31 version = "3.6.2"; 32 godotBuildDescription = "X11 tools"; 33 34 src = fetchFromGitHub { 35 owner = "godotengine"; 36 repo = "godot"; 37 rev = "${self.version}-stable"; 38 hash = "sha256-loNjE+NmHniZ827Eb9MHSNo27F2LrURhWURjUq4d8xw="; 39 }; 40 41 # Fix PIE hardening: https://github.com/godotengine/godot/pull/50737 42 postPatch = '' 43 substituteInPlace platform/x11/detect.py \ 44 --replace-fail 'env.Append(LINKFLAGS=["-no-pie"])' "" 45 ''; 46 47 nativeBuildInputs = [ 48 autoPatchelfHook 49 installShellFiles 50 makeWrapper 51 pkg-config 52 scons 53 ]; 54 55 buildInputs = [ 56 alsa-lib 57 freetype 58 libGLU 59 libpulseaudio 60 libX11 61 libXcursor 62 libXext 63 libXfixes 64 libXi 65 libXinerama 66 libXrandr 67 libXrender 68 openssl 69 udev 70 yasm 71 zlib 72 ]; 73 74 shouldAddLinkFlagsToPulse = true; 75 76 patches = map (rp: ./patches + rp) [ 77 # The version of SConstruct in the godot source appends the OS's PATH to the Scons PATH, 78 # but because it is an append, the Scons PATH takes precedence. The Scons PATH contains a 79 # bunch of standard Linux paths like /usr/bin, so if they happen to contain versions of any 80 # build-time dependencies of Godot, they will be used instead of the Nix version of them. 81 # 82 # This patch simply replaces the entire Scons environment (including the PATH) with that 83 # of the OS. This isn't as surgical as just fixing the PATH, but it seems to work, and 84 # seems to be the Nix community's current strategy when using Scons. 85 /SConstruct/dontClobberEnvironment.patch 86 ]; 87 88 enableParallelBuilding = true; 89 godotBuildPlatform = "x11"; 90 shouldBuildTools = true; 91 godotBuildTarget = "release_debug"; 92 93 lto = if self.godotBuildTarget == "release" then "full" else "none"; 94 95 sconsFlags = [ 96 "arch=${stdenv.hostPlatform.linuxArch}" 97 "platform=${self.godotBuildPlatform}" 98 "tools=${lib.boolToString self.shouldBuildTools}" 99 "target=${self.godotBuildTarget}" 100 "bits=${toString stdenv.hostPlatform.parsed.cpu.bits}" 101 "lto=${self.lto}" 102 ]; 103 104 shouldWrapBinary = self.shouldBuildTools; 105 shouldInstallManual = self.shouldBuildTools; 106 shouldPatchBinary = self.shouldBuildTools; 107 shouldInstallHeaders = self.shouldBuildTools; 108 shouldInstallShortcut = self.shouldBuildTools && self.godotBuildPlatform != "server"; 109 110 outputs = [ 111 "out" 112 ] 113 ++ lib.optional self.shouldInstallManual "man" 114 ++ lib.optional self.shouldBuildTools "dev"; 115 116 builtGodotBinNamePattern = 117 if self.godotBuildPlatform == "server" then "godot_server.*" else "godot.*"; 118 119 godotBinInstallPath = "bin"; 120 installedGodotBinName = self.pname; 121 installedGodotShortcutFileName = "org.godotengine.Godot3.desktop"; 122 installedGodotShortcutDisplayName = "Godot Engine 3"; 123 124 installPhase = '' 125 runHook preInstall 126 127 echo "Installing godot binaries." 128 outbin="$out/$godotBinInstallPath" 129 mkdir -p "$outbin" 130 cp -R bin/. "$outbin" 131 mv "$outbin"/$builtGodotBinNamePattern "$outbin/$installedGodotBinName" 132 133 if [ -n "$shouldWrapBinary" ]; then 134 wrapProgram "$outbin/$installedGodotBinName" \ 135 --set ALSA_PLUGIN_DIR ${alsa-plugins}/lib/alsa-lib 136 fi 137 138 if [ -n "$shouldInstallManual" ]; then 139 echo "Installing godot manual." 140 mansrc=misc/dist/linux 141 mv "$mansrc"/godot.6 "$mansrc"/godot3.6 142 installManPage "$mansrc"/godot3.6 143 fi 144 145 if [ -n "$shouldInstallHeaders" ]; then 146 echo "Installing godot headers." 147 mkdir -p "$dev" 148 cp -R modules/gdnative/include "$dev" 149 fi 150 151 if [ -n "$shouldInstallShortcut" ]; then 152 echo "Installing godot shortcut." 153 mkdir -p "$out"/share/{applications,icons/hicolor/scalable/apps} 154 cp misc/dist/linux/org.godotengine.Godot.desktop "$out"/share/applications/$installedGodotShortcutFileName 155 cp icon.svg "$out"/share/icons/hicolor/scalable/apps/godot.svg 156 cp icon.png "$out"/share/icons/godot.png 157 substituteInPlace "$out"/share/applications/$installedGodotShortcutFileName \ 158 --replace "Exec=godot" "Exec=\"$outbin/$installedGodotBinName\"" \ 159 --replace "Name=Godot Engine" "Name=$installedGodotShortcutDisplayName" 160 fi 161 162 runHook postInstall 163 ''; 164 165 runtimeDependencies = lib.optionals self.shouldPatchBinary ( 166 map lib.getLib [ 167 alsa-lib 168 libpulseaudio 169 udev 170 ] 171 ); 172 173 meta = { 174 homepage = "https://godotengine.org"; 175 description = "Free and Open Source 2D and 3D game engine (" + self.godotBuildDescription + ")"; 176 license = lib.licenses.mit; 177 platforms = [ 178 "i686-linux" 179 "x86_64-linux" 180 "aarch64-linux" 181 ]; 182 mainProgram = "godot3"; 183 maintainers = with lib.maintainers; [ 184 rotaerk 185 twey 186 ]; 187 }; 188})