37 binary-deps-version = "10";
39 src = fetchFromGitHub {
40 owner = "Unvanquished";
41 repo = "Unvanquished";
43 fetchSubmodules = true;
44 sha256 = "sha256-F8U9UBFCe0PcFYZ2DThQwhouO22jKyWb0/ABhprHXCU=";
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/linux-amd64-default_${version}.tar.xz ";
54 sha256 = "sha256-5n8gRvTuke4e7EaZ/5G+dtCG6qmnawhtA1IXIFQPkzA=";
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 = buildFHSEnv {
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-xb8gKQHSyscWM29r0BWK0YsALull9uYjX7e+l1DHFPg=";
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 TARGET="linux-amd64-default_${binary-deps-version}"
139 mkdir daemon/external_deps/"$TARGET"
140 cp -r ${unvanquished-binary-deps}/* daemon/external_deps/"$TARGET"/
141 chmod +w -R daemon/external_deps/"$TARGET"/
144 nativeBuildInputs = [
146 unvanquished-binary-deps
175 "-DUSE_HARDENING=TRUE"
177 "-DOpenGL_GL_PREFERENCE=LEGACY" # https://github.com/DaemonEngine/Daemon/issues/474
182 name = "net.unvanquished.Unvanquished.desktop";
183 desktopName = "Unvanquished";
184 comment = "FPS/RTS Game - Aliens vs. Humans";
185 icon = "unvanquished";
186 exec = "unvanquished";
187 categories = [ "Game" "ActionGame" "StrategyGame" ];
188 prefersNonDefaultGPU = true;
191 name = "net.unvanquished.UnvanquishedProtocolHandler.desktop";
192 desktopName = "Unvanquished (protocol handler)";
194 exec = "unvanquished -connect %u";
195 mimeTypes = [ "x-scheme-handler/unv" ];
196 prefersNonDefaultGPU = true;
203 for f in daemon daemon-tty daemonded nacl_loader nacl_helper_bootstrap; do
204 install -Dm0755 -t $out/lib/ $f
206 install -Dm0644 -t $out/lib/ irt_core-amd64.nexe
209 ${wrapBinary "daemon" "unvanquished"}
210 ${wrapBinary "daemon-tty" "unvanquished-tty"}
211 ${wrapBinary "daemonded" "unvanquished-server"}
213 for d in ${src}/dist/icons/*; do
214 install -Dm0644 -t $out/share/icons/hicolor/$(basename $d)/apps/ $d/unvanquished.png
221 homepage = "https://unvanquished.net/";
222 downloadPage = "https://unvanquished.net/download/";
223 description = "A fast paced, first person strategy game";
224 # don't replace the following lib.licenses.zlib with just "zlib",
225 # or you would end up with the package instead
226 license = with lib.licenses; [
227 mit gpl3Plus lib.licenses.zlib bsd3 # engine
228 cc-by-sa-25 cc-by-sa-30 cc-by-30 cc-by-sa-40 cc0 # assets
230 sourceProvenance = with lib.sourceTypes; [
232 binaryNativeCode # unvanquished-binary-deps
234 maintainers = with lib.maintainers; [ afontain ];
235 platforms = [ "x86_64-linux" ];