7 cmake ? pkgs.cmake_2_8,
12 stdenv = if (cc == null) then pkgs.stdenv
13 else pkgs.overrideCC pkgs.stdenv pkgs."${cc}";
15 cleanSourceFilter = name: type: let
16 baseName = baseNameOf (toString name);
17 result = (lib.cleanSourceFilter name type)
18 && !(lib.hasSuffix ".nix" baseName)
19 && !(type == "directory" && baseName == ".git")
20 && !(type == "directory" && baseName == ".idea")
21 && !(type == "directory" && (lib.hasPrefix "cmake-build-" baseName))
25 localFilesCustom = src: filter:
26 builtins.filterSource (name: type: (cleanSourceFilter name type) && (filter name type)) src
28 localFiles = src: localFilesCustom src (name: type: true);
30 localFilesMain = src: let
31 project = toString ./.;
32 cleanSourceFilterMain = name: type: let
33 baseName = baseNameOf (toString name);
34 result = (cleanSourceFilter name type)
35 && !(name == "${project}/release")
36 && !(name == "${project}/d0_blind_id")
37 && !(name == "${project}/daemon")
38 && !(name == "${project}/darkplaces")
39 && !(name == "${project}/data")
40 && !(name == "${project}/gmqcc")
41 && !(name == "${project}/netradiant")
42 && !(name == "${project}/wiki" || name == "${project}/wiki.yes")
43 && !(name == "${project}/xonstat" || name == "${project}/xonstat.yes")
46 in builtins.filterSource cleanSourceFilterMain src;
49 baseName = baseNameOf (toString name);
51 || (lib.hasSuffix ".txt" baseName)
52 || (lib.hasSuffix ".cmake" baseName)
53 || (lib.hasSuffix ".in" baseName)
54 || (lib.hasSuffix ".sh" baseName)
56 || (lib.hasSuffix ".qc" baseName)
57 || (lib.hasSuffix ".qh" baseName)
58 || (lib.hasSuffix ".inc" baseName)
60 || (lib.hasSuffix ".cfg" baseName)
65 # https://gitlab.com/xonotic/xonotic
66 "xonotic" = localFilesMain ./.;
67 "data/font-dejavu" = localFiles ./data/font-dejavu.pk3dir;
68 "data/font-nimbussansl" = localFiles ./data/font-nimbussansl.pk3dir;
69 "data/font-unifont" = localFiles ./data/font-unifont.pk3dir;
70 "data/font-xolonium" = localFiles ./data/font-xolonium.pk3dir;
72 # https://gitlab.com/xonotic/d0_blind_id
73 "d0_blind_id" = localFiles ./d0_blind_id;
75 # https://gitlab.com/xonotic/darkplaces
76 "darkplaces" = localFiles ./darkplaces;
78 # https://gitlab.com/xonotic/gmqcc
79 "gmqcc" = localFiles ./gmqcc;
81 # https://gitlab.com/xonotic/netradiant
82 "netradiant" = localFiles ./netradiant;
84 # https://gitlab.com/xonotic/xonotic-data.pk3dir
85 "data/xonotic-data" = localFilesCustom ./data/xonotic-data.pk3dir (name: type: type == "directory" || !(isCode name));
86 "data/xonotic-data/qcsrc" = localFilesCustom ./data/xonotic-data.pk3dir (name: type: type == "directory" || (isCode name));
88 # https://gitlab.com/xonotic/xonotic-maps.pk3dir
89 "data/xonotic-maps" = localFiles ./data/xonotic-maps.pk3dir;
91 # https://gitlab.com/xonotic/xonotic-music.pk3dir
92 "data/xonotic-music" = localFiles ./data/xonotic-music.pk3dir;
94 # https://gitlab.com/xonotic/xonotic-nexcompat.pk3dir
95 "data/xonotic-nexcompat" = localFiles ./data/xonotic-nexcompat.pk3dir;
99 font-dejavu = mkDerivation rec {
100 name = "font-dejavu-${version}";
103 src = srcs."data/font-dejavu";
105 phases = [ "installPhase" ];
111 font-nimbussansl = mkDerivation rec {
112 name = "font-nimbussansl-${version}";
115 src = srcs."data/font-nimbussansl";
117 phases = [ "installPhase" ];
123 font-unifont = mkDerivation rec {
124 name = "font-unifont-${version}";
127 src = srcs."data/font-unifont";
129 phases = [ "installPhase" ];
135 font-xolonium = mkDerivation rec {
136 name = "font-xolonium-${version}";
139 src = srcs."data/font-xolonium";
141 phases = [ "installPhase" ];
147 d0_blind_id = mkDerivation rec {
148 name = "d0_blind_id-${version}";
149 version = "xonotic-${VERSION}";
151 src = srcs."d0_blind_id";
153 nativeBuildInputs = [
157 buildInputs = with pkgs; [
163 cp libd0_blind_id.so $out/lib
165 mkdir -p $out/include/d0_blind_id
166 (cd $src; cp d0_blind_id.h d0.h $out/include/d0_blind_id)
171 unwrapped = mkDerivation rec {
172 name = "darkplaces-unwrapped-${version}";
173 version = "xonotic-${VERSION}";
175 src = srcs."darkplaces";
177 nativeBuildInputs = [
181 buildInputs = with pkgs; [
190 cp darkplaces-{dedicated,sdl} $out/bin
193 result = mkDerivation rec {
194 name = "darkplaces-${version}";
195 version = "xonotic-${VERSION}";
197 buildInputs = unwrapped.buildInputs ++ runtimeInputs;
198 runtimeInputs = with pkgs; [
214 phases = [ "installPhase" ];
218 cp -r ${unwrapped}/bin .
222 for exe in darkplaces-sdl; do
223 rpath=$(patchelf --print-rpath $exe)
224 rpath=''${rpath:+$rpath:}${lib.makeLibraryPath runtimeInputs}
225 patchelf --set-rpath $rpath $exe
228 for exe in dedicated sdl; do
229 cp darkplaces-$exe $out/bin/xonotic-linux64-$exe
235 gmqcc = mkDerivation rec {
236 name = "gmqcc-${version}";
237 version = "xonotic-${VERSION}";
241 nativeBuildInputs = [
251 netradiant = mkDerivation rec {
252 name = "netradiant-${version}";
255 src = srcs."netradiant";
257 nativeBuildInputs = with pkgs; [
262 buildInputs = with pkgs; [
287 xonotic-data = mkDerivation rec {
288 name = "xonotic-data-${version}";
289 version = "xonotic-${VERSION}";
291 src = srcs."data/xonotic-data";
293 phases = [ "installPhase" ];
298 find $out -depth -type d -empty -exec rmdir {} \;
302 xonotic-data-code = mkDerivation rec {
303 name = "xonotic-data-code-${version}";
304 version = "xonotic-${VERSION}";
306 src = srcs."data/xonotic-data/qcsrc";
309 QCC = "${gmqcc}/bin/gmqcc";
312 nativeBuildInputs = with pkgs; [
321 cp {menu,progs,csprogs}.{dat,lno} $out
322 find $out -depth -type d -empty -exec rmdir {} \;
326 xonotic = mkDerivation rec {
327 name = "xonotic-${version}";
330 src = srcs."xonotic";
336 phases = [ "installPhase" ];
343 cp ${darkplaces}/bin/* $out
346 ln -s ${font-dejavu} $out/data/font-dejavu.pk3dir
347 ln -s ${font-nimbussansl} $out/data/font-nimbussansl.pk3dir
348 ln -s ${font-unifont} $out/data/font-unifont.pk3dir
349 ln -s ${font-xolonium} $out/data/font-xolonium.pk3dir
351 ln -s ${xonotic-data} $out/data/xonotic-data.pk3dir
352 ln -s ${xonotic-data-code} $out/data/xonotic-data-code.pk3dir
353 ln -s ${srcs."data/xonotic-maps"} $out/data/xonotic-maps.pk3dir # todo: build
354 ln -s ${srcs."data/xonotic-music"} $out/data/xonotic-music.pk3dir
355 ln -s ${srcs."data/xonotic-nexcompat"} $out/data/xonotic-nexcompat.pk3dir
357 mkdir -p $out/mapping
358 ln -s ${netradiant} $out/mapping/${netradiant.name}
363 mkDerivation = {env ? {}, shellHook ? "", runtimeInputs ? [], ...}@args: stdenv.mkDerivation ({}
364 // { enableParallelBuilding = true; }
365 // (removeAttrs args ["env" "shellHook" "runtimeInputs"])
370 ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "export ${n}=${v}") env)}
371 export LD_LIBRARY_PATH=''${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}${lib.makeLibraryPath runtimeInputs}
375 shell = let inputs = (lib.mapAttrsToList (n: v: v) targets); in stdenv.mkDerivation (rec {
376 name = "xonotic-shell";
377 nativeBuildInputs = builtins.map (it: it.nativeBuildInputs) inputs;
378 buildInputs = builtins.map (it: it.buildInputs) inputs;
379 shellHook = builtins.map (it: it.shellHook) (builtins.filter (it: it?shellHook) inputs);
381 in { inherit shell; } // targets