Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchFromGitLab, 5 makeWrapper, 6 pkg-config, 7 nasm, 8 makeDesktopItem, 9 copyDesktopItems, 10 alsa-lib, 11 flac, 12 libvorbis, 13 libvpx, 14 libGL, 15 SDL2, 16 SDL2_mixer, 17 xorg, 18 graphicsmagick, 19 unstableGitUpdater, 20}: 21 22let 23 wrapper = "eduke32-wrapper"; 24 swWrapper = "voidsw-wrapper"; 25 furyWrapper = "fury-wrapper"; 26 27in 28stdenv.mkDerivation (finalAttrs: { 29 pname = "eduke32"; 30 version = "0-unstable-2025-07-04"; 31 32 src = fetchFromGitLab { 33 domain = "voidpoint.io"; 34 owner = "terminx"; 35 repo = "eduke32"; 36 rev = "388752735c68456b89d8acffcb836e6802308007"; 37 hash = "sha256-QQ0qKY/ZK0SwxMkZ76792w7iCO+ZpGWGJutHJW1e5+Q="; 38 deepClone = true; 39 leaveDotGit = true; 40 postFetch = '' 41 cd $out 42 git rev-list --count HEAD > VC_REV 43 rm -rf .git 44 ''; 45 }; 46 47 patches = [ 48 # gdk-pixbuf-csource no longer supports bmp so convert to png 49 # patch GNUMakefile to use graphicsmagick to convert bmp -> png 50 ./convert-bmp-to-png.diff 51 ]; 52 53 buildInputs = [ 54 flac 55 libvorbis 56 libvpx 57 SDL2 58 SDL2_mixer 59 ] 60 ++ lib.optionals stdenv.hostPlatform.isLinux [ 61 alsa-lib 62 libGL 63 xorg.libX11 64 ]; 65 66 nativeBuildInputs = [ 67 makeWrapper 68 pkg-config 69 copyDesktopItems 70 graphicsmagick 71 ] 72 ++ lib.optionals (stdenv.hostPlatform.system == "i686-linux") [ 73 nasm 74 ]; 75 76 postPatch = '' 77 substituteInPlace source/imgui/src/imgui_impl_sdl2.cpp \ 78 --replace-fail '#include <SDL.h>' '#include <SDL2/SDL.h>' \ 79 --replace-fail '#include <SDL_syswm.h>' '#include <SDL2/SDL_syswm.h>' \ 80 --replace-fail '#include <SDL_vulkan.h>' '#include <SDL2/SDL_vulkan.h>' 81 '' 82 + lib.optionalString stdenv.hostPlatform.isLinux '' 83 for f in glad.c glad_wgl.c ; do 84 substituteInPlace source/glad/src/$f \ 85 --replace-fail libGL.so ${libGL}/lib/libGL.so 86 done 87 ''; 88 89 makeFlags = [ 90 "SDLCONFIG=${SDL2}/bin/sdl2-config" 91 "VC_HASH=${lib.substring 0 9 finalAttrs.src.rev}" 92 "VC_BRANCH=master" 93 "HAVE_GTK2=0" 94 ]; 95 96 buildFlags = [ 97 "duke3d" 98 "sw" 99 ]; 100 101 preConfigure = '' 102 appendToVar makeFlags "VC_REV=$(cat VC_REV)" 103 ''; 104 105 desktopItems = [ 106 (makeDesktopItem { 107 name = "eduke32"; 108 icon = "eduke32"; 109 exec = "${wrapper}"; 110 comment = "Duke Nukem 3D port"; 111 desktopName = "Enhanced Duke Nukem 3D"; 112 genericName = "Duke Nukem 3D port"; 113 categories = [ "Game" ]; 114 }) 115 (makeDesktopItem { 116 name = "voidsw"; 117 icon = "voidsw"; 118 exec = "${swWrapper}"; 119 comment = "Shadow Warrior eduke32 source port"; 120 desktopName = "VoidSW"; 121 genericName = "Shadow Warrior source port"; 122 categories = [ "Game" ]; 123 }) 124 (makeDesktopItem { 125 name = "fury"; 126 icon = "fury"; 127 exec = "${furyWrapper}"; 128 comment = "Ion Fury eduke32 source port"; 129 desktopName = "Ion Fury"; 130 genericName = "Ion Fury source port"; 131 categories = [ "Game" ]; 132 }) 133 ]; 134 135 enableParallelBuilding = true; 136 137 installPhase = '' 138 runHook preInstall 139 140 install -Dm755 -t $out/bin eduke32 mapster32 voidsw wangulator 141 '' 142 + lib.optionalString stdenv.hostPlatform.isLinux '' 143 makeWrapper $out/bin/eduke32 $out/bin/${wrapper} \ 144 --set-default EDUKE32_DATA_DIR /var/lib/games/eduke32 \ 145 --add-flags '-j"$EDUKE32_DATA_DIR"' \ 146 --add-flags '-gamegrp DUKE3D.GRP' 147 makeWrapper $out/bin/voidsw $out/bin/${swWrapper} \ 148 --set-default EDUKE32_DATA_DIR /var/lib/games/eduke32 \ 149 --add-flags '-j"$EDUKE32_DATA_DIR"' 150 makeWrapper $out/bin/eduke32 $out/bin/${furyWrapper} \ 151 --set-default EDUKE32_DATA_DIR /var/lib/games/eduke32 \ 152 --add-flags '-j"$EDUKE32_DATA_DIR"' \ 153 --add-flags '-gamegrp FURY.GRP' 154 mkdir -p $out/share/icons/hicolor/scalable/apps 155 gm convert "./source/duke3d/rsrc/game_icon.ico[10]" $out/share/icons/hicolor/scalable/apps/eduke32.png 156 install -Dm644 ./source/sw/rsrc/game_icon.svg $out/share/icons/hicolor/scalable/apps/voidsw.svg 157 gm convert "./source/duke3d/rsrc/fury/game_icon.ico[4]" $out/share/icons/hicolor/scalable/apps/fury.png 158 '' 159 + lib.optionalString stdenv.hostPlatform.isDarwin '' 160 mkdir -p $out/Applications/EDuke32.app/Contents/MacOS 161 mkdir -p $out/Applications/Mapster32.app/Contents/MacOS 162 mkdir -p $out/Applications/VoidSW.app/Contents/MacOS 163 mkdir -p $out/Applications/Wangulator.app/Contents/MacOS 164 165 cp -r platform/Apple/bundles/EDuke32.app/* $out/Applications/EDuke32.app/ 166 cp -r platform/Apple/bundles/Mapster32.app/* $out/Applications/Mapster32.app/ 167 cp -r platform/Apple/bundles/VoidSW.app/* $out/Applications/VoidSW.app/ 168 cp -r platform/Apple/bundles/Wangulator.app/* $out/Applications/Wangulator.app/ 169 170 ln -sf $out/bin/eduke32 $out/Applications/EDuke32.app/Contents/MacOS/eduke32 171 ln -sf $out/bin/mapster32 $out/Applications/Mapster32.app/Contents/MacOS/mapster32 172 ln -sf $out/bin/voidsw $out/Applications/VoidSW.app/Contents/MacOS/voidsw 173 ln -sf $out/bin/wangulator $out/Applications/Wangulator.app/Contents/MacOS/wangulator 174 '' 175 + '' 176 runHook postInstall 177 ''; 178 179 passthru.updateScript = unstableGitUpdater { hardcodeZeroVersion = true; }; 180 181 meta = { 182 description = "Enhanched port of Duke Nukem 3D for various platforms"; 183 homepage = "http://eduke32.com"; 184 license = with lib.licenses; [ gpl2Plus ]; 185 maintainers = with lib.maintainers; [ 186 qubitnano 187 sander 188 ]; 189 platforms = lib.platforms.all; 190 }; 191})