7 cmake ? pkgs.cmake_2_8,
13 # https://gitlab.com/xonotic/xonotic
14 "xonotic" = localFilesMain ./.;
15 "data/font-dejavu" = localFiles ./data/font-dejavu.pk3dir;
16 "data/font-nimbussansl" = localFiles ./data/font-nimbussansl.pk3dir;
17 "data/font-unifont" = localFiles ./data/font-unifont.pk3dir;
18 "data/font-xolonium" = localFiles ./data/font-xolonium.pk3dir;
20 # https://gitlab.com/xonotic/d0_blind_id
21 "d0_blind_id" = localFiles ./d0_blind_id;
23 # https://gitlab.com/xonotic/darkplaces
24 "darkplaces" = localFiles ./darkplaces;
26 # https://gitlab.com/xonotic/gmqcc
27 "gmqcc" = localFiles ./gmqcc;
29 # https://gitlab.com/xonotic/netradiant
30 "netradiant" = localFiles ./netradiant;
32 # https://gitlab.com/xonotic/xonotic-data.pk3dir
33 "data/xonotic-data" = localFilesCustom ./data/xonotic-data.pk3dir (name: type: type == "directory" || !(isCode name));
34 "data/xonotic-data/qcsrc" = localFilesCustom ./data/xonotic-data.pk3dir (name: type: type == "directory" || (isCode name));
36 # https://gitlab.com/xonotic/xonotic-maps.pk3dir
37 "data/xonotic-maps" = localFiles ./data/xonotic-maps.pk3dir;
39 # https://gitlab.com/xonotic/xonotic-music.pk3dir
40 "data/xonotic-music" = localFiles ./data/xonotic-music.pk3dir;
42 # https://gitlab.com/xonotic/xonotic-nexcompat.pk3dir
43 "data/xonotic-nexcompat" = localFiles ./data/xonotic-nexcompat.pk3dir;
46 localFilesMain = src: let
47 project = toString ./.;
48 cleanSourceFilterMain = name: type: let
49 baseName = baseNameOf (toString name);
50 result = (cleanSourceFilter name type)
51 && !(name == "${project}/release")
52 && !(name == "${project}/d0_blind_id")
53 && !(name == "${project}/daemon")
54 && !(name == "${project}/darkplaces")
55 && !(name == "${project}/data")
56 && !(name == "${project}/gmqcc")
57 && !(name == "${project}/netradiant")
58 && !(name == "${project}/wiki" || name == "${project}/wiki.yes")
59 && !(name == "${project}/xonstat" || name == "${project}/xonstat.yes")
62 in builtins.filterSource cleanSourceFilterMain src;
65 baseName = baseNameOf (toString name);
67 || (lib.hasSuffix ".ase" baseName)
68 || (lib.hasSuffix ".dem" baseName)
69 || (lib.hasSuffix ".dpm" baseName)
70 || (lib.hasSuffix ".framegroups" baseName)
71 || (lib.hasSuffix ".iqm" baseName)
72 || (lib.hasSuffix ".jpg" baseName)
73 || (lib.hasSuffix ".lmp" baseName)
74 || (lib.hasSuffix ".md3" baseName)
75 || (lib.hasSuffix ".mdl" baseName)
76 || (lib.hasSuffix ".obj" baseName)
77 || (lib.hasSuffix ".ogg" baseName)
78 || (lib.hasSuffix ".png" baseName)
79 || (lib.hasSuffix ".shader" baseName)
80 || (lib.hasSuffix ".skin" baseName)
81 || (lib.hasSuffix ".sounds" baseName)
82 || (lib.hasSuffix ".sp2" baseName)
83 || (lib.hasSuffix ".spr" baseName)
84 || (lib.hasSuffix ".spr32" baseName)
85 || (lib.hasSuffix ".svg" baseName)
86 || (lib.hasSuffix ".tga" baseName)
87 || (lib.hasSuffix ".wav" baseName)
88 || (lib.hasSuffix ".width" baseName)
89 || (lib.hasSuffix ".zym" baseName)
94 font-dejavu = mkDerivation rec {
95 name = "font-dejavu-${version}";
98 src = srcs."data/font-dejavu";
100 phases = [ "installPhase" ];
106 font-nimbussansl = mkDerivation rec {
107 name = "font-nimbussansl-${version}";
110 src = srcs."data/font-nimbussansl";
112 phases = [ "installPhase" ];
118 font-unifont = mkDerivation rec {
119 name = "font-unifont-${version}";
122 src = srcs."data/font-unifont";
124 phases = [ "installPhase" ];
130 font-xolonium = mkDerivation rec {
131 name = "font-xolonium-${version}";
134 src = srcs."data/font-xolonium";
136 phases = [ "installPhase" ];
142 d0_blind_id = mkDerivation rec {
143 name = "d0_blind_id-${version}";
144 version = "xonotic-${VERSION}";
146 src = srcs."d0_blind_id";
148 nativeBuildInputs = [
152 buildInputs = with pkgs; [
158 cp libd0_blind_id.so $out/lib
160 mkdir -p $out/include/d0_blind_id
161 (cd $src; cp d0_blind_id.h d0.h $out/include/d0_blind_id)
166 unwrapped = mkDerivation rec {
167 name = "darkplaces-unwrapped-${version}";
168 version = "xonotic-${VERSION}";
170 src = srcs."darkplaces";
172 nativeBuildInputs = [
176 buildInputs = with pkgs; [
185 cp darkplaces-{dedicated,sdl} $out/bin
188 result = mkDerivation rec {
189 name = "darkplaces-${version}";
190 version = "xonotic-${VERSION}";
192 buildInputs = unwrapped.buildInputs ++ runtimeInputs;
193 runtimeInputs = with pkgs; [
209 phases = [ "installPhase" ];
213 cp -r ${unwrapped}/bin .
217 for exe in darkplaces-sdl; do
218 rpath=$(patchelf --print-rpath $exe)
219 rpath=''${rpath:+$rpath:}${lib.makeLibraryPath runtimeInputs}
220 patchelf --set-rpath $rpath $exe
223 for exe in dedicated sdl; do
224 cp darkplaces-$exe $out/bin/xonotic-linux64-$exe
230 gmqcc = mkDerivation rec {
231 name = "gmqcc-${version}";
232 version = "xonotic-${VERSION}";
236 nativeBuildInputs = [
246 netradiant = mkDerivation rec {
247 name = "netradiant-${version}";
250 src = srcs."netradiant";
252 nativeBuildInputs = with pkgs; [
257 buildInputs = with pkgs; [
282 xonotic-data = mkDerivation rec {
283 name = "xonotic-data-${version}";
284 version = "xonotic-${VERSION}";
286 src = srcs."data/xonotic-data";
288 phases = [ "installPhase" ];
293 find $out -depth -type d -empty -exec rmdir {} \;
297 xonotic-data-code = mkDerivation rec {
298 name = "xonotic-data-code-${version}";
299 version = "xonotic-${VERSION}";
301 src = srcs."data/xonotic-data/qcsrc";
304 QCC = "${gmqcc}/bin/gmqcc";
307 nativeBuildInputs = with pkgs; [
316 cp {menu,progs,csprogs}.{dat,lno} $out
317 find $out -depth -type d -empty -exec rmdir {} \;
321 xonotic = mkDerivation rec {
322 name = "xonotic-${version}";
325 src = srcs."xonotic";
331 phases = [ "installPhase" ];
338 cp ${darkplaces}/bin/* $out
341 ln -s ${font-dejavu} $out/data/font-dejavu.pk3dir
342 ln -s ${font-nimbussansl} $out/data/font-nimbussansl.pk3dir
343 ln -s ${font-unifont} $out/data/font-unifont.pk3dir
344 ln -s ${font-xolonium} $out/data/font-xolonium.pk3dir
346 ln -s ${xonotic-data} $out/data/xonotic-data.pk3dir
347 ln -s ${xonotic-data-code} $out/data/xonotic-data-code.pk3dir
348 ln -s ${srcs."data/xonotic-maps"} $out/data/xonotic-maps.pk3dir # todo: build
349 ln -s ${srcs."data/xonotic-music"} $out/data/xonotic-music.pk3dir
350 ln -s ${srcs."data/xonotic-nexcompat"} $out/data/xonotic-nexcompat.pk3dir
352 mkdir -p $out/mapping
353 ln -s ${netradiant} $out/mapping/${netradiant.name}
358 cleanSourceFilter = name: type: let
359 baseName = baseNameOf (toString name);
360 result = (lib.cleanSourceFilter name type)
361 && !(lib.hasSuffix ".nix" baseName)
362 && !(type == "directory" && baseName == ".git")
363 && !(type == "directory" && baseName == ".idea")
364 && !(type == "directory" && (lib.hasPrefix "cmake-build-" baseName))
368 localFilesCustom = src: filter:
369 builtins.filterSource (name: type: (cleanSourceFilter name type) && (filter name type)) src
372 localFiles = src: localFilesCustom src (name: type: true);
374 stdenv = if (cc == null) then pkgs.stdenv
375 else pkgs.overrideCC pkgs.stdenv pkgs."${cc}";
377 mkDerivation = {env ? {}, shellHook ? "", runtimeInputs ? [], ...}@args: stdenv.mkDerivation ({}
378 // { enableParallelBuilding = true; }
379 // (removeAttrs args ["env" "shellHook" "runtimeInputs"])
384 ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "export ${n}=${v}") env)}
385 export LD_LIBRARY_PATH=''${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}${lib.makeLibraryPath runtimeInputs}
390 shell = let inputs = (lib.mapAttrsToList (n: v: v) targets); in stdenv.mkDerivation (rec {
391 name = "xonotic-shell";
392 nativeBuildInputs = builtins.map (it: it.nativeBuildInputs) inputs;
393 buildInputs = builtins.map (it: it.buildInputs) inputs;
394 shellHook = builtins.map (it: it.shellHook) (builtins.filter (it: it?shellHook) inputs);
396 in { inherit shell; } // targets