From c434f513cd97c4d8f16d8e531b179568a15aec3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Mon, 27 Jul 2020 18:05:19 +0100 Subject: [PATCH] Use a full entrypoint instead of a runAsRoot script for minecraft This needs to be done because the server does not support qemu, and NixOS requires qemu to use the runAsRoot feature for docker images. Instead, create the required files as part of the entrypoint. Fixes #6 --- etc/nixos/services/minecraft.nix | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/etc/nixos/services/minecraft.nix b/etc/nixos/services/minecraft.nix index 5a1bb10..9f6e99b 100644 --- a/etc/nixos/services/minecraft.nix +++ b/etc/nixos/services/minecraft.nix @@ -1,6 +1,14 @@ { pkgs, ... }: let + entrypoint = pkgs.writeScript "entrypoint.sh" '' + #!${pkgs.bash}/bin/bash + ${pkgs.busybox}/bin/mkdir -p /var/lib/ + ${pkgs.gzip}/bin/gzip -dc ${./configs/minecraft.tar.gz} | ${pkgs.gnutar}/bin/tar -xf - -C /var/lib + echo 'eula=true' > /var/lib/minecraft/eula.txt + cp -f ${properties} /var/lib/minecraft + $@ + ''; ops = pkgs.writeText "ops.json" (builtins.toJSON [ { uuid = "140d177a-966f-41b8-a4c0-e305babd291b"; @@ -72,13 +80,8 @@ in imageFile = pkgs.dockerTools.buildImage { name = "tlaternet/minecraft"; tag = "latest"; - runAsRoot = '' - mkdir -p /var/lib/ - ${pkgs.gzip}/bin/gzip -dc ${./configs/minecraft.tar.gz} | ${pkgs.gnutar}/bin/tar -xf - -C /var/lib - echo 'eula=true' > /var/lib/minecraft/eula.txt - cp -f ${properties} /var/lib/minecraft - ''; config = { + Entrypoint = [ "${entrypoint}" ]; Cmd = [ "${pkgs.jre_headless}/bin/java" "-Xms2G" "-Xmx2G"