Merge pull request #312518 from dali99/bluemap

bluemap: init at 3.21, and init module

authored by Peder Bergebakken Sundt and committed by GitHub 64076cea c079625a

+344
+2
nixos/doc/manual/release-notes/rl-2405.section.md
··· 180 181 - [Clevis](https://github.com/latchset/clevis), a pluggable framework for automated decryption, used to unlock encrypted devices in initrd. Available as [boot.initrd.clevis.enable](#opt-boot.initrd.clevis.enable). 182 183 - [fritz-exporter](https://github.com/pdreker/fritz_exporter), a Prometheus exporter for extracting metrics from [FRITZ!](https://avm.de/produkte/) devices. Available as [services.prometheus.exporters.fritz](#opt-services.prometheus.exporters.fritz.enable). 184 185 - [armagetronad](https://wiki.armagetronad.org), a mid-2000s 3D lightcycle game widely played at iD Tech Camps. You can define multiple servers using `services.armagetronad.<server>.enable`.
··· 180 181 - [Clevis](https://github.com/latchset/clevis), a pluggable framework for automated decryption, used to unlock encrypted devices in initrd. Available as [boot.initrd.clevis.enable](#opt-boot.initrd.clevis.enable). 182 183 + - [Bluemap](https://bluemap.bluecolored.de/), a 3D minecraft map renderer. Available as [services.bluemap](#opt-services.bluemap.enable). 184 + 185 - [fritz-exporter](https://github.com/pdreker/fritz_exporter), a Prometheus exporter for extracting metrics from [FRITZ!](https://avm.de/produkte/) devices. Available as [services.prometheus.exporters.fritz](#opt-services.prometheus.exporters.fritz.enable). 186 187 - [armagetronad](https://wiki.armagetronad.org), a mid-2000s 3D lightcycle game widely played at iD Tech Camps. You can define multiple servers using `services.armagetronad.<server>.enable`.
+1
nixos/modules/module-list.nix
··· 1444 ./services/web-apps/zitadel.nix 1445 ./services/web-servers/agate.nix 1446 ./services/web-servers/apache-httpd/default.nix 1447 ./services/web-servers/caddy/default.nix 1448 ./services/web-servers/darkhttpd.nix 1449 ./services/web-servers/fcgiwrap.nix
··· 1444 ./services/web-apps/zitadel.nix 1445 ./services/web-servers/agate.nix 1446 ./services/web-servers/apache-httpd/default.nix 1447 + ./services/web-servers/bluemap.nix 1448 ./services/web-servers/caddy/default.nix 1449 ./services/web-servers/darkhttpd.nix 1450 ./services/web-servers/fcgiwrap.nix
+311
nixos/modules/services/web-servers/bluemap.nix
···
··· 1 + { config, lib, pkgs, ... }: 2 + let 3 + cfg = config.services.bluemap; 4 + format = pkgs.formats.hocon { }; 5 + 6 + coreConfig = format.generate "core.conf" cfg.coreSettings; 7 + webappConfig = format.generate "webapp.conf" cfg.webappSettings; 8 + webserverConfig = format.generate "webserver.conf" cfg.webserverSettings; 9 + 10 + mapsFolder = pkgs.linkFarm "maps" 11 + (lib.attrsets.mapAttrs' (name: value: 12 + lib.nameValuePair "${name}.conf" 13 + (format.generate "${name}.conf" value)) 14 + cfg.maps); 15 + 16 + storageFolder = pkgs.linkFarm "storage" 17 + (lib.attrsets.mapAttrs' (name: value: 18 + lib.nameValuePair "${name}.conf" 19 + (format.generate "${name}.conf" value)) 20 + cfg.storage); 21 + 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; 29 + }; 30 + 31 + inherit (lib) mkOption; 32 + in { 33 + options.services.bluemap = { 34 + enable = lib.mkEnableOption "bluemap"; 35 + 36 + eula = mkOption { 37 + type = lib.types.bool; 38 + description = '' 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. 41 + ''; 42 + default = false; 43 + }; 44 + 45 + defaultWorld = mkOption { 46 + type = lib.types.path; 47 + description = '' 48 + The world used by the default map ruleset. 49 + If you configure your own maps you do not need to set this. 50 + ''; 51 + example = lib.literalExpression "\${config.services.minecraft.dataDir}/world"; 52 + }; 53 + 54 + enableRender = mkOption { 55 + type = lib.types.bool; 56 + description = "Enable rendering"; 57 + default = true; 58 + }; 59 + 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"; 64 + }; 65 + 66 + enableNginx = mkOption { 67 + type = lib.types.bool; 68 + default = true; 69 + description = "Enable configuring a virtualHost for serving the bluemap webapp"; 70 + }; 71 + 72 + host = mkOption { 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"; 77 + }; 78 + 79 + onCalendar = mkOption { 80 + type = lib.types.str; 81 + description = '' 82 + How often to trigger rendering the map, 83 + in the format of a systemd timer onCalendar configuration. 84 + See {manpage}`systemd.timer(5)`. 85 + ''; 86 + default = "*-*-* 03:10:00"; 87 + }; 88 + 89 + coreSettings = mkOption { 90 + type = lib.types.submodule { 91 + freeformType = format.type; 92 + options = { 93 + data = mkOption { 94 + type = lib.types.path; 95 + description = "Folder for where bluemap stores its data"; 96 + default = "/var/lib/bluemap"; 97 + }; 98 + metrics = lib.mkEnableOption "Sending usage metrics containing the version of bluemap in use"; 99 + }; 100 + }; 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)."; 102 + }; 103 + 104 + webappSettings = mkOption { 105 + type = lib.types.submodule { 106 + freeformType = format.type; 107 + }; 108 + default = { 109 + enabled = true; 110 + webroot = cfg.webRoot; 111 + }; 112 + defaultText = lib.literalExpression '' 113 + { 114 + enabled = true; 115 + webroot = config.services.bluemap.webRoot; 116 + } 117 + ''; 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)."; 119 + }; 120 + 121 + webserverSettings = mkOption { 122 + type = lib.types.submodule { 123 + freeformType = format.type; 124 + options = { 125 + enabled = mkOption { 126 + type = lib.types.bool; 127 + description = '' 128 + Enable bluemap's built-in webserver. 129 + Disabled by default in nixos for use of nginx directly. 130 + ''; 131 + default = false; 132 + }; 133 + }; 134 + }; 135 + default = { }; 136 + description = '' 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). 139 + ''; 140 + }; 141 + 142 + maps = mkOption { 143 + type = lib.types.attrsOf (lib.types.submodule { 144 + freeformType = format.type; 145 + options = { 146 + world = lib.mkOption { 147 + type = lib.types.path; 148 + description = "Path to world folder containing the dimension to render"; 149 + }; 150 + }; 151 + }); 152 + default = { 153 + "overworld" = { 154 + world = "${cfg.defaultWorld}"; 155 + ambient-light = 0.1; 156 + cave-detection-ocean-floor = -5; 157 + }; 158 + 159 + "nether" = { 160 + world = "${cfg.defaultWorld}/DIM-1"; 161 + sorting = 100; 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; 169 + max-y = 90; 170 + }; 171 + 172 + "end" = { 173 + world = "${cfg.defaultWorld}/DIM1"; 174 + sorting = 200; 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; 181 + }; 182 + }; 183 + defaultText = lib.literalExpression '' 184 + { 185 + "overworld" = { 186 + world = "''${cfg.defaultWorld}"; 187 + ambient-light = 0.1; 188 + cave-detection-ocean-floor = -5; 189 + }; 190 + 191 + "nether" = { 192 + world = "''${cfg.defaultWorld}/DIM-1"; 193 + sorting = 100; 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; 201 + max-y = 90; 202 + }; 203 + 204 + "end" = { 205 + world = "''${cfg.defaultWorld}/DIM1"; 206 + sorting = 200; 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; 213 + }; 214 + }; 215 + ''; 216 + description = '' 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). 221 + ''; 222 + }; 223 + 224 + storage = mkOption { 225 + type = lib.types.attrsOf (lib.types.submodule { 226 + freeformType = format.type; 227 + options = { 228 + storage-type = mkOption { 229 + type = lib.types.enum [ "FILE" "SQL" ]; 230 + description = "Type of storage config"; 231 + default = "FILE"; 232 + }; 233 + }; 234 + }); 235 + description = '' 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) 239 + ''; 240 + default = { 241 + "file" = { 242 + root = "${cfg.webRoot}/maps"; 243 + }; 244 + }; 245 + defaultText = lib.literalExpression '' 246 + { 247 + "file" = { 248 + root = "''${config.services.bluemap.webRoot}/maps"; 249 + }; 250 + } 251 + ''; 252 + }; 253 + 254 + resourcepacks = mkOption { 255 + type = lib.types.attrsOf lib.types.pathInStore; 256 + default = { }; 257 + description = "A set of resourcepacks to use, loaded in alphabetical order"; 258 + }; 259 + }; 260 + 261 + 262 + config = lib.mkIf cfg.enable { 263 + assertions = 264 + [ { assertion = config.services.bluemap.eula; 265 + message = '' 266 + You have enabled bluemap but have not accepted minecraft's EULA. 267 + You can achieve this through setting `services.bluemap.eula = true` 268 + ''; 269 + } 270 + ]; 271 + 272 + services.bluemap.coreSettings.accept-download = cfg.eula; 273 + 274 + systemd.services."render-bluemap-maps" = lib.mkIf cfg.enableRender { 275 + serviceConfig = { 276 + Type = "oneshot"; 277 + Group = "nginx"; 278 + UMask = "026"; 279 + }; 280 + script = '' 281 + ${lib.getExe pkgs.bluemap} -c ${configFolder} -gs -r 282 + ''; 283 + }; 284 + 285 + systemd.timers."render-bluemap-maps" = lib.mkIf cfg.enableRender { 286 + wantedBy = [ "timers.target" ]; 287 + timerConfig = { 288 + OnCalendar = cfg.onCalendar; 289 + Persistent = true; 290 + Unit = "render-bluemap-maps.service"; 291 + }; 292 + }; 293 + 294 + services.nginx.virtualHosts = lib.mkIf cfg.enableNginx { 295 + "${cfg.host}" = { 296 + root = config.services.bluemap.webRoot; 297 + locations = { 298 + "~* ^/maps/[^/]*/tiles/[^/]*.json$".extraConfig = '' 299 + error_page 404 =200 /assets/emptyTile.json; 300 + gzip_static always; 301 + ''; 302 + "~* ^/maps/[^/]*/tiles/[^/]*.png$".tryFiles = "$uri =204"; 303 + }; 304 + }; 305 + }; 306 + }; 307 + 308 + meta = { 309 + maintainers = with lib.maintainers; [ dandellion h7x4 ]; 310 + }; 311 + }
+30
pkgs/by-name/bl/bluemap/package.nix
···
··· 1 + { lib, stdenvNoCC, fetchurl, makeWrapper, jre }: 2 + 3 + stdenvNoCC.mkDerivation rec { 4 + pname = "bluemap"; 5 + version = "3.21"; 6 + 7 + src = fetchurl { 8 + url = "https://github.com/BlueMap-Minecraft/BlueMap/releases/download/v${version}/BlueMap-${version}-cli.jar"; 9 + hash = "sha256-YWf69+nsMfqk2x9xGTt+tdnGvaU+6rPsiBLWsP89ngM="; 10 + }; 11 + 12 + dontUnpack = true; 13 + 14 + nativeBuildInputs = [ makeWrapper ]; 15 + 16 + installPhase = '' 17 + runHook preInstall 18 + makeWrapper ${jre}/bin/java $out/bin/bluemap --add-flags "-jar $src" 19 + runHook postInstall 20 + ''; 21 + 22 + meta = { 23 + description = "3D minecraft map renderer"; 24 + homepage = "https://bluemap.bluecolored.de/"; 25 + sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; 26 + license = lib.licenses.mit; 27 + maintainers = with lib.maintainers; [ dandellion h7x4 ]; 28 + mainProgram = "bluemap"; 29 + }; 30 + }