···
1
+
{ config, lib, pkgs, ... }:
3
+
cfg = config.services.bluemap;
4
+
format = pkgs.formats.hocon { };
6
+
coreConfig = format.generate "core.conf" cfg.coreSettings;
7
+
webappConfig = format.generate "webapp.conf" cfg.webappSettings;
8
+
webserverConfig = format.generate "webserver.conf" cfg.webserverSettings;
10
+
mapsFolder = pkgs.linkFarm "maps"
11
+
(lib.attrsets.mapAttrs' (name: value:
12
+
lib.nameValuePair "${name}.conf"
13
+
(format.generate "${name}.conf" value))
16
+
storageFolder = pkgs.linkFarm "storage"
17
+
(lib.attrsets.mapAttrs' (name: value:
18
+
lib.nameValuePair "${name}.conf"
19
+
(format.generate "${name}.conf" value))
22
+
configFolder = pkgs.linkFarm "bluemap-config" {
23
+
"maps" = mapsFolder;
24
+
"storages" = storageFolder;
25
+
"core.conf" = coreConfig;
26
+
"webapp.conf" = webappConfig;
27
+
"webserver.conf" = webserverConfig;
28
+
"resourcepacks" = pkgs.linkFarm "resourcepacks" cfg.resourcepacks;
31
+
inherit (lib) mkOption;
33
+
options.services.bluemap = {
34
+
enable = lib.mkEnableOption "bluemap";
37
+
type = lib.types.bool;
39
+
By changing this option to true you confirm that you own a copy of minecraft Java Edition,
40
+
and that you agree to minecrafts EULA.
45
+
defaultWorld = mkOption {
46
+
type = lib.types.path;
48
+
The world used by the default map ruleset.
49
+
If you configure your own maps you do not need to set this.
51
+
example = lib.literalExpression "\${config.services.minecraft.dataDir}/world";
54
+
enableRender = mkOption {
55
+
type = lib.types.bool;
56
+
description = "Enable rendering";
60
+
webRoot = mkOption {
61
+
type = lib.types.path;
62
+
default = "/var/lib/bluemap/web";
63
+
description = "The directory for saving and serving the webapp and the maps";
66
+
enableNginx = mkOption {
67
+
type = lib.types.bool;
69
+
description = "Enable configuring a virtualHost for serving the bluemap webapp";
73
+
type = lib.types.str;
74
+
default = "bluemap.${config.networking.domain}";
75
+
defaultText = lib.literalExpression "bluemap.\${config.networking.domain}";
76
+
description = "Domain to configure nginx for";
79
+
onCalendar = mkOption {
80
+
type = lib.types.str;
82
+
How often to trigger rendering the map,
83
+
in the format of a systemd timer onCalendar configuration.
84
+
See {manpage}`systemd.timer(5)`.
86
+
default = "*-*-* 03:10:00";
89
+
coreSettings = mkOption {
90
+
type = lib.types.submodule {
91
+
freeformType = format.type;
94
+
type = lib.types.path;
95
+
description = "Folder for where bluemap stores its data";
96
+
default = "/var/lib/bluemap";
98
+
metrics = lib.mkEnableOption "Sending usage metrics containing the version of bluemap in use";
101
+
description = "Settings for the core.conf file, [see upstream docs](https://github.com/BlueMap-Minecraft/BlueMap/blob/master/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/core.conf).";
104
+
webappSettings = mkOption {
105
+
type = lib.types.submodule {
106
+
freeformType = format.type;
110
+
webroot = cfg.webRoot;
112
+
defaultText = lib.literalExpression ''
115
+
webroot = config.services.bluemap.webRoot;
118
+
description = "Settings for the webapp.conf file, see [upstream docs](https://github.com/BlueMap-Minecraft/BlueMap/blob/master/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/webapp.conf).";
121
+
webserverSettings = mkOption {
122
+
type = lib.types.submodule {
123
+
freeformType = format.type;
125
+
enabled = mkOption {
126
+
type = lib.types.bool;
128
+
Enable bluemap's built-in webserver.
129
+
Disabled by default in nixos for use of nginx directly.
137
+
Settings for the webserver.conf file, usually not required.
138
+
[See upstream docs](https://github.com/BlueMap-Minecraft/BlueMap/blob/master/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/webserver.conf).
143
+
type = lib.types.attrsOf (lib.types.submodule {
144
+
freeformType = format.type;
146
+
world = lib.mkOption {
147
+
type = lib.types.path;
148
+
description = "Path to world folder containing the dimension to render";
154
+
world = "${cfg.defaultWorld}";
155
+
ambient-light = 0.1;
156
+
cave-detection-ocean-floor = -5;
160
+
world = "${cfg.defaultWorld}/DIM-1";
162
+
sky-color = "#290000";
163
+
void-color = "#150000";
164
+
ambient-light = 0.6;
165
+
world-sky-light = 0;
166
+
remove-caves-below-y = -10000;
167
+
cave-detection-ocean-floor = -5;
168
+
cave-detection-uses-block-light = true;
173
+
world = "${cfg.defaultWorld}/DIM1";
175
+
sky-color = "#080010";
176
+
void-color = "#080010";
177
+
ambient-light = 0.6;
178
+
world-sky-light = 0;
179
+
remove-caves-below-y = -10000;
180
+
cave-detection-ocean-floor = -5;
183
+
defaultText = lib.literalExpression ''
186
+
world = "''${cfg.defaultWorld}";
187
+
ambient-light = 0.1;
188
+
cave-detection-ocean-floor = -5;
192
+
world = "''${cfg.defaultWorld}/DIM-1";
194
+
sky-color = "#290000";
195
+
void-color = "#150000";
196
+
ambient-light = 0.6;
197
+
world-sky-light = 0;
198
+
remove-caves-below-y = -10000;
199
+
cave-detection-ocean-floor = -5;
200
+
cave-detection-uses-block-light = true;
205
+
world = "''${cfg.defaultWorld}/DIM1";
207
+
sky-color = "#080010";
208
+
void-color = "#080010";
209
+
ambient-light = 0.6;
210
+
world-sky-light = 0;
211
+
remove-caves-below-y = -10000;
212
+
cave-detection-ocean-floor = -5;
217
+
Settings for files in `maps/`.
218
+
If you define anything here you must define everything yourself.
219
+
See the default for an example with good options for the different world types.
220
+
For valid values [consult upstream docs](https://github.com/BlueMap-Minecraft/BlueMap/blob/master/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf).
224
+
storage = mkOption {
225
+
type = lib.types.attrsOf (lib.types.submodule {
226
+
freeformType = format.type;
228
+
storage-type = mkOption {
229
+
type = lib.types.enum [ "FILE" "SQL" ];
230
+
description = "Type of storage config";
236
+
Where the rendered map will be stored.
237
+
Unless you are doing something advanced you should probably leave this alone and configure webRoot instead.
238
+
[See upstream docs](https://github.com/BlueMap-Minecraft/BlueMap/tree/master/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/storages)
242
+
root = "${cfg.webRoot}/maps";
245
+
defaultText = lib.literalExpression ''
248
+
root = "''${config.services.bluemap.webRoot}/maps";
254
+
resourcepacks = mkOption {
255
+
type = lib.types.attrsOf lib.types.pathInStore;
257
+
description = "A set of resourcepacks to use, loaded in alphabetical order";
262
+
config = lib.mkIf cfg.enable {
264
+
[ { assertion = config.services.bluemap.eula;
266
+
You have enabled bluemap but have not accepted minecraft's EULA.
267
+
You can achieve this through setting `services.bluemap.eula = true`
272
+
services.bluemap.coreSettings.accept-download = cfg.eula;
274
+
systemd.services."render-bluemap-maps" = lib.mkIf cfg.enableRender {
281
+
${lib.getExe pkgs.bluemap} -c ${configFolder} -gs -r
285
+
systemd.timers."render-bluemap-maps" = lib.mkIf cfg.enableRender {
286
+
wantedBy = [ "timers.target" ];
288
+
OnCalendar = cfg.onCalendar;
290
+
Unit = "render-bluemap-maps.service";
294
+
services.nginx.virtualHosts = lib.mkIf cfg.enableNginx {
296
+
root = config.services.bluemap.webRoot;
298
+
"~* ^/maps/[^/]*/tiles/[^/]*.json$".extraConfig = ''
299
+
error_page 404 =200 /assets/emptyTile.json;
300
+
gzip_static always;
302
+
"~* ^/maps/[^/]*/tiles/[^/]*.png$".tryFiles = "$uri =204";
309
+
maintainers = with lib.maintainers; [ dandellion h7x4 ];