1# Cataclysm: Dark Days Ahead {#cataclysm-dark-days-ahead}
2
3## How to install Cataclysm DDA {#how-to-install-cataclysm-dda}
4
5To install the latest stable release of Cataclysm DDA to your profile, execute
6`nix-env -f "<nixpkgs>" -iA cataclysm-dda`. For the curses build (build
7without tiles), install `cataclysmDDA.stable.curses`. Note: `cataclysm-dda` is
8an alias to `cataclysmDDA.stable.tiles`.
9
10If you like access to a development build of your favorite git revision,
11override `cataclysm-dda-git` (or `cataclysmDDA.git.curses` if you like curses
12build):
13
14```nix
15cataclysm-dda-git.override {
16 version = "YYYY-MM-DD";
17 rev = "YOUR_FAVORITE_REVISION";
18 sha256 = "CHECKSUM_OF_THE_REVISION";
19}
20```
21
22The sha256 checksum can be obtained by
23
24```sh
25nix-prefetch-url --unpack "https://github.com/CleverRaven/Cataclysm-DDA/archive/${YOUR_FAVORITE_REVISION}.tar.gz"
26```
27
28The default configuration directory is `~/.cataclysm-dda`. If you prefer
29`$XDG_CONFIG_HOME/cataclysm-dda`, override the derivation:
30
31```nix
32cataclysm-dda.override {
33 useXdgDir = true;
34}
35```
36
37## Important note for overriding packages {#important-note-for-overriding-packages}
38
39After applying `overrideAttrs`, you need to fix `passthru.pkgs` and
40`passthru.withMods` attributes either manually or by using `attachPkgs`:
41
42```nix
43let
44 # You enabled parallel building.
45 myCDDA = cataclysm-dda-git.overrideAttrs (_: {
46 enableParallelBuilding = true;
47 });
48
49 # Unfortunately, this refers to the package before overriding and
50 # parallel building is still disabled.
51 badExample = myCDDA.withMods (_: [ ]);
52
53 inherit (cataclysmDDA) attachPkgs pkgs wrapCDDA;
54
55 # You can fix it by hand
56 goodExample1 = myCDDA.overrideAttrs (old: {
57 passthru = old.passthru // {
58 pkgs = pkgs.override { build = goodExample1; };
59 withMods = wrapCDDA goodExample1;
60 };
61 });
62
63 # or by using a helper function `attachPkgs`.
64 goodExample2 = attachPkgs pkgs myCDDA;
65in
66
67# badExample # parallel building disabled
68# goodExample1.withMods (_: []) # parallel building enabled
69goodExample2.withMods (_: [ ]) # parallel building enabled
70```
71
72## Customizing with mods {#customizing-with-mods}
73
74To install Cataclysm DDA with mods of your choice, you can use `withMods`
75attribute:
76
77```nix
78cataclysm-dda.withMods (
79 mods: with mods; [
80 tileset.UndeadPeople
81 ]
82)
83```
84
85All mods, soundpacks, and tilesets available in nixpkgs are found in
86`cataclysmDDA.pkgs`.
87
88Here is an example to modify existing mods and/or add more mods not available
89in nixpkgs:
90
91```nix
92let
93 customMods =
94 self: super:
95 lib.recursiveUpdate super {
96 # Modify existing mod
97 tileset.UndeadPeople = super.tileset.UndeadPeople.overrideAttrs (old: {
98 # If you like to apply a patch to the tileset for example
99 patches = [ ./path/to/your.patch ];
100 });
101
102 # Add another mod
103 mod.Awesome = cataclysmDDA.buildMod {
104 modName = "Awesome";
105 version = "0.x";
106 src = fetchFromGitHub {
107 owner = "Someone";
108 repo = "AwesomeMod";
109 rev = "...";
110 hash = "...";
111 };
112 # Path to be installed in the unpacked source (default: ".")
113 modRoot = "contents/under/this/path/will/be/installed";
114 };
115
116 # Add another soundpack
117 soundpack.Fantastic = cataclysmDDA.buildSoundPack {
118 # ditto
119 };
120
121 # Add another tileset
122 tileset.SuperDuper = cataclysmDDA.buildTileSet {
123 # ditto
124 };
125 };
126in
127cataclysm-dda.withMods (
128 mods: with mods.extend customMods; [
129 tileset.UndeadPeople
130 mod.Awesome
131 soundpack.Fantastic
132 tileset.SuperDuper
133 ]
134)
135```