2024-07-20 18:46:31 +07:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
name = "minecraft";
|
|
|
|
podman = config.profile.podman;
|
2024-07-20 22:01:43 +07:00
|
|
|
inherit (lib) mkIf strings;
|
2024-07-20 18:46:31 +07:00
|
|
|
ip = "10.88.200.1";
|
2024-07-20 22:01:43 +07:00
|
|
|
# image = "docker.io/05jchambers/legendary-minecraft-purpur-geyser:latest";
|
|
|
|
image = "docker.io/itzg/minecraft-bedrock-server:latest";
|
|
|
|
rootVolume = "/nas/podman/minecraft/hutasuhut";
|
2024-07-20 18:46:31 +07:00
|
|
|
domain = "${name}.tigor.web.id";
|
|
|
|
user = config.profile.user;
|
|
|
|
uid = toString user.uid;
|
|
|
|
gid = toString user.gid;
|
2024-07-20 22:01:43 +07:00
|
|
|
users = [
|
|
|
|
{
|
|
|
|
username = "CrowFX7414";
|
|
|
|
xuid = "2533274941938385";
|
|
|
|
}
|
|
|
|
];
|
2024-07-20 18:46:31 +07:00
|
|
|
in
|
|
|
|
{
|
|
|
|
config = mkIf (podman.enable && podman.${name}.enable) {
|
|
|
|
services.caddy.virtualHosts.${domain}.extraConfig = /*html*/ ''
|
|
|
|
header Content-Type text/html
|
|
|
|
respond <<EOF
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Minecraft Server</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Congrats! The minecraft server should be up!</h1>
|
2024-07-20 22:01:43 +07:00
|
|
|
<h2>
|
|
|
|
This server is invitation only.
|
|
|
|
Please contact the server owner for more info.
|
|
|
|
</h2>
|
|
|
|
<p>Server Address: <b>${domain}</b></p>
|
|
|
|
<p>Server Port: <b>19132</b></p>
|
2024-07-20 18:46:31 +07:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF 200
|
|
|
|
'';
|
|
|
|
|
|
|
|
system.activationScripts."podman-${name}" = ''
|
|
|
|
mkdir -p ${rootVolume}
|
|
|
|
chown ${uid}:${gid} ${rootVolume}
|
|
|
|
'';
|
|
|
|
|
|
|
|
virtualisation.oci-containers.containers.${name} = {
|
|
|
|
inherit image;
|
|
|
|
hostname = name;
|
|
|
|
autoStart = true;
|
|
|
|
user = "${uid}:${gid}";
|
|
|
|
environment = {
|
2024-07-20 22:01:43 +07:00
|
|
|
UID = uid;
|
|
|
|
GID = gid;
|
|
|
|
EULA = "TRUE";
|
2024-07-20 18:46:31 +07:00
|
|
|
TZ = "Asia/Jakarta";
|
2024-07-20 22:01:43 +07:00
|
|
|
SERVER_NAME = "Hutasuhut";
|
|
|
|
DEFAULT_PLAYER_PERMISSION_LEVEL = "operator";
|
|
|
|
LEVEL_NAME = "Hutasuhut";
|
|
|
|
MAX_THREADS = "0"; # Use as many as possible
|
|
|
|
ALLOW_LIST_USERS = strings.concatStringsSep "," (
|
|
|
|
map (user: "${user.username}:${user.xuid}") users
|
|
|
|
);
|
2024-07-20 18:46:31 +07:00
|
|
|
};
|
|
|
|
ports = [
|
|
|
|
# Java Edition Ports
|
2024-07-20 22:01:43 +07:00
|
|
|
# "25565:25565/udp"
|
|
|
|
# "25565:25565"
|
2024-07-20 18:46:31 +07:00
|
|
|
# Bedrock Edition Ports
|
|
|
|
"19132:19132/udp"
|
|
|
|
"19132:19132"
|
|
|
|
];
|
|
|
|
volumes = [
|
2024-07-20 22:01:43 +07:00
|
|
|
"${rootVolume}:/data"
|
2024-07-20 18:46:31 +07:00
|
|
|
];
|
|
|
|
extraOptions = [
|
|
|
|
"--network=podman"
|
|
|
|
"--ip=${ip}"
|
|
|
|
];
|
|
|
|
labels = {
|
|
|
|
"io.containers.autoupdate" = "registry";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|