37 binary-deps-version = "6";
39 src = fetchFromGitHub {
40 owner = "Unvanquished";
41 repo = "Unvanquished";
43 fetchSubmodules = true;
44 sha256 = "sha256-VqMhA6GEYh/m+dzOgXS+5Jqo4x7RrQf4qIwstdTTU+E=";
47 unvanquished-binary-deps = stdenv.mkDerivation rec {
48 # DISCLAIMER: this is selected binary crap from the NaCl SDK
49 name = "unvanquished-binary-deps";
50 version = binary-deps-version;
53 url = "https://dl.unvanquished.net/deps/linux64-${version}.tar.bz2";
54 sha256 = "sha256-ERfg89oTf9JTtv/qRnTRIzFP+zMpHT8W4WAIxqogy9E=";
60 # We are not using the autoPatchelfHook, because it would make
61 # nacl_bootstrap_helper unable to load nacl_loader:
62 # "nacl_loader: ELF file has unreasonable e_phnum=13"
63 interpreter="$(< "$NIX_CC/nix-support/dynamic-linker")"
64 for f in pnacl/bin/*; do
65 if [ -f "$f" && -x "$f" ]; then
67 patchelf --set-interpreter "$interpreter" "$f"
73 # check it links correctly
87 libstdcpp-preload-for-unvanquished-nacl = stdenv.mkDerivation {
88 name = "libstdcpp-preload-for-unvanquished-nacl";
90 propagatedBuildInputs = [ gcc.cc.lib ];
94 echo ${gcc.cc.lib}/lib/libstdc++.so.6 > $out/etc/ld-nix.so.preload
98 fhsEnv = buildFHSUserEnv {
99 name = "unvanquished-fhs-wrapper";
101 targetPkgs = pkgs: [ libstdcpp-preload-for-unvanquished-nacl ];
104 wrapBinary = binary: wrappername: ''
105 cat > $out/lib/${binary}-wrapper <<-EOT
107 exec $out/lib/${binary} -pakpath ${unvanquished-assets} "\$@"
109 chmod +x $out/lib/${binary}-wrapper
111 cat > $out/bin/${wrappername} <<-EOT
113 exec ${fhsEnv}/bin/unvanquished-fhs-wrapper $out/lib/${binary}-wrapper "\$@"
115 chmod +x $out/bin/${wrappername}
118 unvanquished-assets = stdenv.mkDerivation {
119 pname = "unvanquished-assets";
122 outputHash = "sha256-MPqyqcZGc5KlkftGCspWhISBJ/h+Os29g7ZK6yWz0cQ=";
123 outputHashMode = "recursive";
125 nativeBuildInputs = [ aria2 cacert ];
128 bash $src/download-paks --cache=$(pwd) --version=${version} $out
132 # this really is the daemon game engine, the game itself is in the assets
133 in stdenv.mkDerivation rec {
134 pname = "unvanquished";
135 inherit version src binary-deps-version;
138 mkdir daemon/external_deps/linux64-${binary-deps-version}/
139 cp -r ${unvanquished-binary-deps}/* daemon/external_deps/linux64-${binary-deps-version}/
140 chmod +w -R daemon/external_deps/linux64-${binary-deps-version}/
143 nativeBuildInputs = [
145 unvanquished-binary-deps
174 "-DUSE_HARDENING=TRUE"
176 "-DOpenGL_GL_PREFERENCE=LEGACY" # https://github.com/DaemonEngine/Daemon/issues/474
181 name = "net.unvanquished.Unvanquished.desktop";
182 desktopName = "Unvanquished";
183 comment = "FPS/RTS Game - Aliens vs. Humans";
184 icon = "unvanquished";
185 exec = "unvanquished";
186 categories = [ "Game" "ActionGame" "StrategyGame" ];
187 prefersNonDefaultGPU = true;
190 name = "net.unvanquished.UnvanquishedProtocolHandler.desktop";
191 desktopName = "Unvanquished (protocol handler)";
193 exec = "unvanquished -connect %u";
194 mimeTypes = [ "x-scheme-handler/unv" ];
195 prefersNonDefaultGPU = true;
202 for f in daemon daemon-tty daemonded nacl_loader nacl_helper_bootstrap; do
203 install -Dm0755 -t $out/lib/ $f
205 install -Dm0644 -t $out/lib/ irt_core-x86_64.nexe
208 ${wrapBinary "daemon" "unvanquished"}
209 ${wrapBinary "daemon-tty" "unvanquished-tty"}
210 ${wrapBinary "daemonded" "unvanquished-server"}
212 for d in ${src}/dist/icons/*; do
213 install -Dm0644 -t $out/share/icons/hicolor/$(basename $d)/apps/ $d/unvanquished.png
220 homepage = "https://unvanquished.net/";
221 downloadPage = "https://unvanquished.net/download/";
222 description = "A fast paced, first person strategy game";
223 # don't replace the following lib.licenses.zlib with just "zlib",
224 # or you would end up with the package instead
225 license = with lib.licenses; [
226 mit gpl3Plus lib.licenses.zlib bsd3 # engine
227 cc-by-sa-25 cc-by-sa-30 cc-by-30 cc-by-sa-40 cc0 # assets
229 sourceProvenance = with lib.sourceTypes; [
231 binaryNativeCode # unvanquished-binary-deps
233 maintainers = with lib.maintainers; [ afontain ];
234 platforms = [ "x86_64-linux" ];