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" {
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";
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";
74 description = "Domain on which nginx will serve the bluemap webapp";
77 onCalendar = mkOption {
80 How often to trigger rendering the map,
81 in the format of a systemd timer onCalendar configuration.
82 See {manpage}`systemd.timer(5)`.
84 default = "*-*-* 03:10:00";
87 coreSettings = mkOption {
88 type = lib.types.submodule {
89 freeformType = format.type;
92 type = lib.types.path;
93 description = "Folder for where bluemap stores its data";
94 default = "/var/lib/bluemap";
96 metrics = lib.mkEnableOption "Sending usage metrics containing the version of bluemap in use";
99 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).";
102 webappSettings = mkOption {
103 type = lib.types.submodule {
104 freeformType = format.type;
108 webroot = cfg.webRoot;
110 defaultText = lib.literalExpression ''
113 webroot = config.services.bluemap.webRoot;
116 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).";
119 webserverSettings = mkOption {
120 type = lib.types.submodule {
121 freeformType = format.type;
124 type = lib.types.bool;
126 Enable bluemap's built-in webserver.
127 Disabled by default in nixos for use of nginx directly.
135 Settings for the webserver.conf file, usually not required.
136 [See upstream docs](https://github.com/BlueMap-Minecraft/BlueMap/blob/master/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/webserver.conf).
141 type = lib.types.attrsOf (lib.types.submodule {
142 freeformType = format.type;
144 world = lib.mkOption {
145 type = lib.types.path;
146 description = "Path to world folder containing the dimension to render";
152 world = "${cfg.defaultWorld}";
154 cave-detection-ocean-floor = -5;
158 world = "${cfg.defaultWorld}/DIM-1";
160 sky-color = "#290000";
161 void-color = "#150000";
164 remove-caves-below-y = -10000;
165 cave-detection-ocean-floor = -5;
166 cave-detection-uses-block-light = true;
171 world = "${cfg.defaultWorld}/DIM1";
173 sky-color = "#080010";
174 void-color = "#080010";
177 remove-caves-below-y = -10000;
178 cave-detection-ocean-floor = -5;
181 defaultText = lib.literalExpression ''
184 world = "''${cfg.defaultWorld}";
186 cave-detection-ocean-floor = -5;
190 world = "''${cfg.defaultWorld}/DIM-1";
192 sky-color = "#290000";
193 void-color = "#150000";
196 remove-caves-below-y = -10000;
197 cave-detection-ocean-floor = -5;
198 cave-detection-uses-block-light = true;
203 world = "''${cfg.defaultWorld}/DIM1";
205 sky-color = "#080010";
206 void-color = "#080010";
209 remove-caves-below-y = -10000;
210 cave-detection-ocean-floor = -5;
215 Settings for files in `maps/`.
216 If you define anything here you must define everything yourself.
217 See the default for an example with good options for the different world types.
218 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).
223 type = lib.types.attrsOf (lib.types.submodule {
224 freeformType = format.type;
226 storage-type = mkOption {
227 type = lib.types.enum [ "FILE" "SQL" ];
228 description = "Type of storage config";
234 Where the rendered map will be stored.
235 Unless you are doing something advanced you should probably leave this alone and configure webRoot instead.
236 [See upstream docs](https://github.com/BlueMap-Minecraft/BlueMap/tree/master/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/storages)
240 root = "${cfg.webRoot}/maps";
243 defaultText = lib.literalExpression ''
246 root = "''${config.services.bluemap.webRoot}/maps";
252 resourcepacks = mkOption {
253 type = lib.types.attrsOf lib.types.pathInStore;
255 description = "A set of resourcepacks to use, loaded in alphabetical order";
260 config = lib.mkIf cfg.enable {
262 [ { assertion = config.services.bluemap.eula;
264 You have enabled bluemap but have not accepted minecraft's EULA.
265 You can achieve this through setting `services.bluemap.eula = true`
270 services.bluemap.coreSettings.accept-download = cfg.eula;
272 systemd.services."render-bluemap-maps" = lib.mkIf cfg.enableRender {
279 ${lib.getExe pkgs.bluemap} -c ${configFolder} -gs -r
283 systemd.timers."render-bluemap-maps" = lib.mkIf cfg.enableRender {
284 wantedBy = [ "timers.target" ];
286 OnCalendar = cfg.onCalendar;
288 Unit = "render-bluemap-maps.service";
292 services.nginx.virtualHosts = lib.mkIf cfg.enableNginx {
294 root = config.services.bluemap.webRoot;
296 "~* ^/maps/[^/]*/tiles/[^/]*.json$".extraConfig = ''
297 error_page 404 =200 /assets/emptyTile.json;
300 "~* ^/maps/[^/]*/tiles/[^/]*.png$".tryFiles = "$uri =204";
307 maintainers = with lib.maintainers; [ dandellion h7x4 ];