36 binary-deps-version = "10";
38 src = fetchFromGitHub {
39 owner = "Unvanquished";
40 repo = "Unvanquished";
42 fetchSubmodules = true;
43 hash = "sha256-4ONge+GnrpV/FHKuA66o7uK7jIygBYizZl8JAUr8x/0=";
46 unvanquished-binary-deps = stdenv.mkDerivation rec {
47 # DISCLAIMER: this is selected binary crap from the NaCl SDK
48 name = "unvanquished-binary-deps";
49 version = binary-deps-version;
52 url = "https://dl.unvanquished.net/deps/linux-amd64-default_${version}.tar.xz ";
53 hash = "sha256-5n8gRvTuke4e7EaZ/5G+dtCG6qmnawhtA1IXIFQPkzA=";
59 # We are not using the autoPatchelfHook, because it would make
60 # nacl_bootstrap_helper unable to load nacl_loader:
61 # "nacl_loader: ELF file has unreasonable e_phnum=13"
62 interpreter="$(< "$NIX_CC/nix-support/dynamic-linker")"
63 for f in pnacl/bin/*; do
64 if [ -f "$f" && -x "$f" ]; then
66 patchelf --set-interpreter "$interpreter" "$f"
72 # check it links correctly
86 libstdcpp-preload-for-unvanquished-nacl = stdenv.mkDerivation {
87 name = "libstdcpp-preload-for-unvanquished-nacl";
89 propagatedBuildInputs = [ gcc.cc.lib ];
93 echo ${gcc.cc.lib}/lib/libstdc++.so.6 > $out/etc/ld-nix.so.preload
97 fhsEnv = buildFHSEnv {
98 name = "unvanquished-fhs-wrapper";
100 targetPkgs = pkgs: [ libstdcpp-preload-for-unvanquished-nacl ];
103 wrapBinary = binary: wrappername: ''
104 cat > $out/lib/${binary}-wrapper <<-EOT
106 exec $out/lib/${binary} -pakpath ${unvanquished-assets} "\$@"
108 chmod +x $out/lib/${binary}-wrapper
110 cat > $out/bin/${wrappername} <<-EOT
112 exec ${fhsEnv}/bin/unvanquished-fhs-wrapper $out/lib/${binary}-wrapper "\$@"
114 chmod +x $out/bin/${wrappername}
117 unvanquished-assets = stdenv.mkDerivation {
118 pname = "unvanquished-assets";
121 outputHash = "sha256-FDDhwBvmv4EvmSh5g6Cb0HYLuY9T++k7q8egxzo04J8=";
122 outputHashMode = "recursive";
124 nativeBuildInputs = [ aria2 cacert ];
127 bash $src/download-paks --cache=$(pwd) --version=${version} $out
131 # this really is the daemon game engine, the game itself is in the assets
132 in stdenv.mkDerivation rec {
133 pname = "unvanquished";
134 inherit version src binary-deps-version;
137 TARGET="linux-amd64-default_${binary-deps-version}"
138 mkdir daemon/external_deps/"$TARGET"
139 cp -r ${unvanquished-binary-deps}/* daemon/external_deps/"$TARGET"/
140 chmod +w -R daemon/external_deps/"$TARGET"/
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-amd64.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 = "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" ];