1{
2 lib,
3 stdenv,
4 runtimeShell,
5 pkg-config,
6 gettext,
7 ncurses,
8 tiles,
9 SDL2,
10 SDL2_image,
11 SDL2_mixer,
12 SDL2_ttf,
13 libX11,
14 freetype,
15 zlib,
16 debug,
17 useXdgDir,
18}:
19
20let
21 inherit (lib) optionals optionalString;
22
23 commonDeps = [
24 gettext
25 zlib
26 ];
27
28 cursesDeps = commonDeps ++ [ ncurses ];
29
30 tilesDeps = commonDeps ++ [
31 SDL2
32 SDL2_image
33 SDL2_mixer
34 SDL2_ttf
35 libX11
36 freetype
37 ];
38
39 patchDesktopFile = ''
40 substituteInPlace $out/share/applications/org.cataclysmdda.CataclysmDDA.desktop \
41 --replace-fail "Exec=cataclysm-tiles" "Exec=$out/bin/cataclysm-tiles"
42 '';
43
44 installMacOSAppLauncher = ''
45 app=$out/Applications/Cataclysm.app
46 install -D -m 444 build-data/osx/Info.plist -t $app/Contents
47 install -D -m 444 build-data/osx/AppIcon.icns -t $app/Contents/Resources
48 mkdir $app/Contents/MacOS
49 launcher=$app/Contents/MacOS/Cataclysm.sh
50 cat << EOF > $launcher
51 #!${runtimeShell}
52 $out/bin/cataclysm-tiles
53 EOF
54 chmod 555 $launcher
55 '';
56in
57
58stdenv.mkDerivation {
59 pname = "cataclysm-dda";
60
61 nativeBuildInputs = [ pkg-config ];
62
63 buildInputs = if tiles then tilesDeps else cursesDeps;
64
65 postPatch = ''
66 patchShebangs lang/compile_mo.sh
67 '';
68
69 makeFlags = [
70 "PREFIX=$(out)"
71 "LANGUAGES=all"
72 (if useXdgDir then "USE_XDG_DIR=1" else "USE_HOME_DIR=1")
73 ]
74 ++ optionals (!debug) [
75 "RELEASE=1"
76 ]
77 ++ optionals tiles [
78 "TILES=1"
79 "SOUND=1"
80 ]
81 ++ optionals stdenv.hostPlatform.isDarwin [
82 "NATIVE=osx"
83 "CLANG=1"
84 "OSX_MIN=${stdenv.hostPlatform.darwinMinVersion}"
85 ];
86
87 postInstall = optionalString tiles (
88 if !stdenv.hostPlatform.isDarwin then patchDesktopFile else installMacOSAppLauncher
89 );
90
91 dontStrip = debug;
92 enableParallelBuilding = true;
93
94 passthru = {
95 isTiles = tiles;
96 isCurses = !tiles;
97 };
98
99 meta = with lib; {
100 description = "Free, post apocalyptic, zombie infested rogue-like";
101 mainProgram = "cataclysm-tiles";
102 longDescription = ''
103 Cataclysm: Dark Days Ahead is a roguelike set in a post-apocalyptic world.
104 Surviving is difficult: you have been thrown, ill-equipped, into a
105 landscape now riddled with monstrosities of which flesh eating zombies are
106 neither the strangest nor the deadliest.
107
108 Yet with care and a little luck, many things are possible. You may try to
109 eke out an existence in the forests silently executing threats and
110 providing sustenance with your longbow. You can ride into town in a
111 jerry-rigged vehicle, all guns blazing, to settle matters in a fug of
112 smoke from your molotovs. You could take a more measured approach and
113 construct an impregnable fortress, surrounded by traps to protect you from
114 the horrors without. The longer you survive, the more skilled and adapted
115 you will get and the better equipped and armed to deal with the threats
116 you are presented with.
117
118 In the course of your ordeal there will be opportunities and temptations
119 to improve or change your very nature. There are tales of survivors fitted
120 with extraordinary cybernetics giving great power and stories too of
121 gravely mutated survivors who, warped by their ingestion of exotic
122 substances or radiation, now more closely resemble insects, birds or fish
123 than their original form.
124 '';
125 homepage = "https://cataclysmdda.org/";
126 license = licenses.cc-by-sa-30;
127 maintainers = with maintainers; [
128 mnacamura
129 DeeUnderscore
130 ];
131 platforms = platforms.unix;
132 };
133}