4 # for it in $(nix-build -A dockerImage --no-out-link); do docker load -i $it; done
8 cmake ? pkgs.cmake_2_8,
14 # https://gitlab.com/xonotic/xonotic
15 "xonotic" = localFilesMain ./.;
16 "data/font-dejavu" = localFiles ./data/font-dejavu.pk3dir;
17 "data/font-nimbussansl" = localFiles ./data/font-nimbussansl.pk3dir;
18 "data/font-unifont" = localFiles ./data/font-unifont.pk3dir;
19 "data/font-xolonium" = localFiles ./data/font-xolonium.pk3dir;
21 # https://gitlab.com/xonotic/d0_blind_id
22 "d0_blind_id" = localFiles ./d0_blind_id;
24 # https://gitlab.com/xonotic/darkplaces
25 "darkplaces" = localFiles ./darkplaces;
27 # https://gitlab.com/xonotic/gmqcc
28 "gmqcc" = localFiles ./gmqcc;
30 # https://gitlab.com/xonotic/netradiant
31 "netradiant" = localFiles ./netradiant;
33 # https://gitlab.com/xonotic/xonotic-data.pk3dir
34 "data/xonotic-data" = localFilesCustom ./data/xonotic-data.pk3dir (name: type: type == "directory" || !(isCode name));
35 "data/xonotic-data/qcsrc" = localFilesCustom ./data/xonotic-data.pk3dir (name: type: type == "directory" || (isCode name));
37 # https://gitlab.com/xonotic/xonotic-maps.pk3dir
38 "data/xonotic-maps" = localFiles ./data/xonotic-maps.pk3dir;
40 # https://gitlab.com/xonotic/xonotic-music.pk3dir
41 "data/xonotic-music" = localFiles ./data/xonotic-music.pk3dir;
43 # https://gitlab.com/xonotic/xonotic-nexcompat.pk3dir
44 "data/xonotic-nexcompat" = localFiles ./data/xonotic-nexcompat.pk3dir;
47 localFilesMain = src: let
48 project = toString ./.;
49 cleanSourceFilterMain = name: type: let
50 baseName = baseNameOf (toString name);
51 result = (cleanSourceFilter name type)
52 && !(name == "${project}/release")
53 && !(name == "${project}/d0_blind_id")
54 && !(name == "${project}/daemon")
55 && !(name == "${project}/darkplaces")
56 && !(name == "${project}/data")
57 && !(name == "${project}/gmqcc")
58 && !(name == "${project}/netradiant")
59 && !(name == "${project}/wiki" || name == "${project}/wiki.yes")
60 && !(name == "${project}/xonstat" || name == "${project}/xonstat.yes")
63 in builtins.filterSource cleanSourceFilterMain src;
66 baseName = baseNameOf (toString name);
68 || (lib.hasSuffix ".ase" baseName)
69 || (lib.hasSuffix ".dem" baseName)
70 || (lib.hasSuffix ".dpm" baseName)
71 || (lib.hasSuffix ".framegroups" baseName)
72 || (lib.hasSuffix ".iqm" baseName)
73 || (lib.hasSuffix ".jpg" baseName)
74 || (lib.hasSuffix ".lmp" baseName)
75 || (lib.hasSuffix ".md3" baseName)
76 || (lib.hasSuffix ".mdl" baseName)
77 || (lib.hasSuffix ".obj" baseName)
78 || (lib.hasSuffix ".ogg" baseName)
79 || (lib.hasSuffix ".png" baseName)
80 || (lib.hasSuffix ".shader" baseName)
81 || (lib.hasSuffix ".skin" baseName)
82 || (lib.hasSuffix ".sounds" baseName)
83 || (lib.hasSuffix ".sp2" baseName)
84 || (lib.hasSuffix ".spr" baseName)
85 || (lib.hasSuffix ".spr32" baseName)
86 || (lib.hasSuffix ".svg" baseName)
87 || (lib.hasSuffix ".tga" baseName)
88 || (lib.hasSuffix ".wav" baseName)
89 || (lib.hasSuffix ".width" baseName)
90 || (lib.hasSuffix ".zym" baseName)
94 pk3 = drv: mkDerivation {
95 name = "${drv.name}.pk3";
96 version = drv.version;
98 nativeBuildInputs = with pkgs; [
102 phases = [ "installPhase" ];
104 (cd ${drv} && zip -r ${drv.pk3args or ""} $out .)
109 font-dejavu = mkDerivation rec {
110 name = "font-dejavu-${version}";
113 src = srcs."data/font-dejavu";
115 phases = [ "installPhase" ];
121 font-nimbussansl = mkDerivation rec {
122 name = "font-nimbussansl-${version}";
125 src = srcs."data/font-nimbussansl";
127 phases = [ "installPhase" ];
133 font-unifont = mkDerivation rec {
134 name = "font-unifont-${version}";
137 src = srcs."data/font-unifont";
139 phases = [ "installPhase" ];
145 font-xolonium = mkDerivation rec {
146 name = "font-xolonium-${version}";
149 src = srcs."data/font-xolonium";
151 phases = [ "installPhase" ];
157 d0_blind_id = mkDerivation rec {
158 name = "d0_blind_id-${version}";
159 version = "xonotic-${VERSION}";
161 src = srcs."d0_blind_id";
163 nativeBuildInputs = [
167 buildInputs = with pkgs; [
173 cp libd0_blind_id.so $out/lib
175 mkdir -p $out/include/d0_blind_id
176 (cd $src; cp d0_blind_id.h d0.h $out/include/d0_blind_id)
181 unwrapped = mkDerivation rec {
182 name = "darkplaces-unwrapped-${version}";
183 version = "xonotic-${VERSION}";
185 src = srcs."darkplaces";
187 nativeBuildInputs = [
191 buildInputs = with pkgs; [
200 cp darkplaces-{dedicated,sdl} $out/bin
203 result = mkDerivation rec {
204 name = "darkplaces-${version}";
205 version = "xonotic-${VERSION}";
207 buildInputs = unwrapped.buildInputs ++ runtimeInputs;
208 runtimeInputs = with pkgs; [
224 phases = [ "installPhase" ];
228 cp -r ${unwrapped}/bin .
232 for exe in darkplaces-sdl; do
233 rpath=$(patchelf --print-rpath $exe)
234 rpath=''${rpath:+$rpath:}${lib.makeLibraryPath runtimeInputs}
235 patchelf --set-rpath $rpath $exe
238 for exe in dedicated sdl; do
239 cp darkplaces-$exe $out/bin/xonotic-linux64-$exe
245 gmqcc = mkDerivation rec {
246 name = "gmqcc-${version}";
247 version = "xonotic-${VERSION}";
251 nativeBuildInputs = [
261 netradiant = mkDerivation rec {
262 name = "netradiant-${version}";
265 src = srcs."netradiant";
267 nativeBuildInputs = with pkgs; [
272 buildInputs = with pkgs; [
297 xonotic-data = mkDerivation rec {
298 name = "xonotic-data-${version}";
299 version = "xonotic-${VERSION}";
301 src = srcs."data/xonotic-data";
303 phases = [ "installPhase" ];
308 find $out -depth -type d -empty -exec rmdir {} \;
312 xonotic-data-code = mkDerivation rec {
313 name = "xonotic-data-code-${version}";
314 version = "xonotic-${VERSION}";
316 src = srcs."data/xonotic-data/qcsrc";
319 QCC = "${gmqcc}/bin/gmqcc";
322 nativeBuildInputs = with pkgs; [
331 cp {menu,progs,csprogs}.{dat,lno} $out
332 find $out -depth -type d -empty -exec rmdir {} \;
337 xonotic-maps = mkDerivation rec {
338 name = "xonotic-maps-${version}";
339 version = "xonotic-${VERSION}";
341 src = srcs."data/xonotic-maps";
343 phases = [ "installPhase" ];
350 xonotic-music = mkDerivation rec {
351 name = "xonotic-music-${version}";
352 version = "xonotic-${VERSION}";
354 src = srcs."data/xonotic-music";
356 phases = [ "installPhase" ];
362 passthru.pk3args = "-0";
365 xonotic-nexcompat = mkDerivation rec {
366 name = "xonotic-nexcompat-${version}";
367 version = "xonotic-${VERSION}";
369 src = srcs."data/xonotic-nexcompat";
371 phases = [ "installPhase" ];
378 xonotic = mkDerivation rec {
379 name = "xonotic-${version}";
382 src = srcs."xonotic";
402 phases = [ "installPhase" ];
407 cp ${darkplaces}/bin/* $out
410 ${lib.concatStringsSep "\n" (lib.mapAttrsToList (k: v:
411 # "cp ${pk3 v} $out/data/${k}.pk3"
412 "ln -s ${v} $out/data/${k}.pk3dir"
415 mkdir -p $out/mapping
416 ln -s ${netradiant} $out/mapping/${netradiant.name}
421 main = pkgs.dockerTools.buildImage {
424 contents = mkDerivation {
425 name = "xonotic-init";
426 phases = [ "installPhase" ];
429 cat > $out/init <<EOF
431 ${pkgs.coreutils}/bin/ls -l /data
432 exec ${darkplaces}/bin/xonotic-linux64-dedicated
437 config.Entrypoint = "/init";
439 unpackImage = { name, from, to }: pkgs.dockerTools.buildImage {
440 name = "xonotic_${name}";
442 contents = mkDerivation {
443 name = "xonotic-${name}-init";
444 phases = [ "installPhase" ];
447 cat > $out/init <<EOF
449 ${pkgs.coreutils}/bin/cp -r ${from} /data/${to}
454 config.Entrypoint = "/init";
457 // (lib.mapAttrs (k: v: unpackImage { name = k; from = pk3 v; to = "${k}.pk3"; }) xonotic.paks)
461 cleanSourceFilter = name: type: let
462 baseName = baseNameOf (toString name);
463 result = (lib.cleanSourceFilter name type)
464 && !(lib.hasSuffix ".nix" baseName)
465 && !(type == "directory" && baseName == ".git")
466 && !(type == "directory" && baseName == ".idea")
467 && !(type == "directory" && (lib.hasPrefix "cmake-build-" baseName))
471 localFilesCustom = src: filter:
472 builtins.filterSource (name: type: (cleanSourceFilter name type) && (filter name type)) src
475 localFiles = src: localFilesCustom src (name: type: true);
477 stdenv = if (cc == null) then pkgs.stdenv
478 else pkgs.overrideCC pkgs.stdenv pkgs."${cc}";
480 mkDerivation = {env ? {}, shellHook ? "", runtimeInputs ? [], ...}@args: stdenv.mkDerivation ({}
481 // { enableParallelBuilding = true; }
482 // (removeAttrs args ["env" "shellHook" "runtimeInputs"])
487 ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "export ${n}=${v}") env)}
488 export LD_LIBRARY_PATH=''${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}${lib.makeLibraryPath runtimeInputs}
493 shell = let inputs = (lib.mapAttrsToList (k: v: v) targets); in stdenv.mkDerivation (rec {
494 name = "xonotic-shell";
495 nativeBuildInputs = builtins.map (it: it.nativeBuildInputs) (builtins.filter (it: it?nativeBuildInputs) inputs);
496 buildInputs = builtins.map (it: it.buildInputs) (builtins.filter (it: it?buildInputs) inputs);
497 shellHook = builtins.map (it: it.shellHook) (builtins.filter (it: it?shellHook) inputs);
499 in { inherit shell; } // targets