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 addonsFolder = pkgs.linkFarm "addons"
17 (lib.attrsets.mapAttrs' (name: value: lib.nameValuePair "${name}.jar" value) cfg.addons);
19 storageFolder = pkgs.linkFarm "storage"
20 (lib.attrsets.mapAttrs' (name: value:
21 lib.nameValuePair "${name}.conf"
22 (format.generate "${name}.conf" value))
25 configFolder = pkgs.linkFarm "bluemap-config" {
27 "storages" = storageFolder;
28 "core.conf" = coreConfig;
29 "webapp.conf" = webappConfig;
30 "webserver.conf" = webserverConfig;
31 "packs" = pkgs.linkFarm "packs" cfg.resourcepacks;
32 "addons" = addonsFolder;
35 inherit (lib) mkOption;
38 (lib.mkRenamedOptionModule [ "services" "bluemap" "resourcepacks" ] [ "services" "bluemap" "packs" ])
41 options.services.bluemap = {
42 enable = lib.mkEnableOption "bluemap";
45 type = lib.types.bool;
47 By changing this option to true you confirm that you own a copy of minecraft Java Edition,
48 and that you agree to minecrafts EULA.
53 defaultWorld = mkOption {
54 type = lib.types.path;
56 The world used by the default map ruleset.
57 If you configure your own maps you do not need to set this.
59 example = lib.literalExpression "\${config.services.minecraft.dataDir}/world";
62 enableRender = mkOption {
63 type = lib.types.bool;
64 description = "Enable rendering";
69 type = lib.types.path;
70 default = "/var/lib/bluemap/web";
71 description = "The directory for saving and serving the webapp and the maps";
74 enableNginx = mkOption {
75 type = lib.types.bool;
77 description = "Enable configuring a virtualHost for serving the bluemap webapp";
82 description = "Domain on which nginx will serve the bluemap webapp";
85 onCalendar = mkOption {
88 How often to trigger rendering the map,
89 in the format of a systemd timer onCalendar configuration.
90 See {manpage}`systemd.timer(5)`.
92 default = "*-*-* 03:10:00";
95 coreSettings = mkOption {
96 type = lib.types.submodule {
97 freeformType = format.type;
100 type = lib.types.path;
101 description = "Folder for where bluemap stores its data";
102 default = "/var/lib/bluemap";
104 metrics = lib.mkEnableOption "Sending usage metrics containing the version of bluemap in use";
107 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).";
110 webappSettings = mkOption {
111 type = lib.types.submodule {
112 freeformType = format.type;
116 webroot = cfg.webRoot;
118 defaultText = lib.literalExpression ''
121 webroot = config.services.bluemap.webRoot;
124 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).";
127 webserverSettings = mkOption {
128 type = lib.types.submodule {
129 freeformType = format.type;
132 type = lib.types.bool;
134 Enable bluemap's built-in webserver.
135 Disabled by default in nixos for use of nginx directly.
143 Settings for the webserver.conf file, usually not required.
144 [See upstream docs](https://github.com/BlueMap-Minecraft/BlueMap/blob/master/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/webserver.conf).
149 type = lib.types.attrsOf (lib.types.submodule {
150 freeformType = format.type;
152 world = lib.mkOption {
153 type = lib.types.path;
154 description = "Path to world folder containing the dimension to render";
160 world = "${cfg.defaultWorld}";
162 cave-detection-ocean-floor = -5;
166 world = "${cfg.defaultWorld}/DIM-1";
168 sky-color = "#290000";
169 void-color = "#150000";
172 remove-caves-below-y = -10000;
173 cave-detection-ocean-floor = -5;
174 cave-detection-uses-block-light = true;
179 world = "${cfg.defaultWorld}/DIM1";
181 sky-color = "#080010";
182 void-color = "#080010";
185 remove-caves-below-y = -10000;
186 cave-detection-ocean-floor = -5;
189 defaultText = lib.literalExpression ''
192 world = "''${cfg.defaultWorld}";
194 cave-detection-ocean-floor = -5;
198 world = "''${cfg.defaultWorld}/DIM-1";
200 sky-color = "#290000";
201 void-color = "#150000";
204 remove-caves-below-y = -10000;
205 cave-detection-ocean-floor = -5;
206 cave-detection-uses-block-light = true;
211 world = "''${cfg.defaultWorld}/DIM1";
213 sky-color = "#080010";
214 void-color = "#080010";
217 remove-caves-below-y = -10000;
218 cave-detection-ocean-floor = -5;
223 Settings for files in `maps/`.
224 If you define anything here you must define everything yourself.
225 See the default for an example with good options for the different world types.
226 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).
231 type = lib.types.attrsOf lib.types.pathInStore;
234 A set of jar addons to be loaded.
236 See <https://bluemap.bluecolored.de/3rdPartySupport.html> for a list of officially recognized addons.
239 example = lib.literalExpression ''
241 blueBridge = ./blueBridge.jar;
242 blueBorder = pkgs.fetchurl {
243 url = "https://github.com/pop4959/BlueBorder/releases/download/1.1.1/BlueBorder-1.1.1.jar";
251 type = lib.types.attrsOf (lib.types.submodule {
252 freeformType = format.type;
254 storage-type = mkOption {
255 type = lib.types.enum [ "FILE" "SQL" ];
256 description = "Type of storage config";
262 Where the rendered map will be stored.
263 Unless you are doing something advanced you should probably leave this alone and configure webRoot instead.
264 [See upstream docs](https://github.com/BlueMap-Minecraft/BlueMap/tree/master/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/storages)
268 root = "${cfg.webRoot}/maps";
271 defaultText = lib.literalExpression ''
274 root = "''${config.services.bluemap.webRoot}/maps";
281 type = lib.types.attrsOf lib.types.pathInStore;
284 A set of resourcepacks, datapacks, and mods to extract resources from,
285 loaded in alphabetical order.
291 config = lib.mkIf cfg.enable {
293 [ { assertion = config.services.bluemap.eula;
295 You have enabled bluemap but have not accepted minecraft's EULA.
296 You can achieve this through setting `services.bluemap.eula = true`
301 services.bluemap.coreSettings.accept-download = cfg.eula;
303 systemd.services."render-bluemap-maps" = lib.mkIf cfg.enableRender {
310 ${lib.getExe pkgs.bluemap} -c ${configFolder} -gs -r
314 systemd.timers."render-bluemap-maps" = lib.mkIf cfg.enableRender {
315 wantedBy = [ "timers.target" ];
317 OnCalendar = cfg.onCalendar;
319 Unit = "render-bluemap-maps.service";
323 services.nginx.virtualHosts = lib.mkIf cfg.enableNginx {
325 root = config.services.bluemap.webRoot;
327 "@empty".return = "204";
329 "~* ^/maps/[^/]*/tiles/".extraConfig = ''
330 error_page 404 = @empty;
339 maintainers = with lib.maintainers; [ dandellion h7x4 ];