2024-10-21 12:31:30 +07:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-07-20 18:46:31 +07:00
|
|
|
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-08-04 15:52:32 +07:00
|
|
|
image = "docker.io/05jchambers/legendary-minecraft-purpur-geyser:latest";
|
|
|
|
# image = "docker.io/itzg/minecraft-bedrock-server:latest";
|
|
|
|
rootVolume = "/nas/podman/minecraft/hutasuhut-geyser";
|
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-26 20:01:55 +07:00
|
|
|
{
|
|
|
|
username = "cherlyxroblox";
|
|
|
|
xuid = "2535436320975546";
|
|
|
|
}
|
2024-07-20 22:01:43 +07:00
|
|
|
];
|
2024-07-20 18:46:31 +07:00
|
|
|
in
|
|
|
|
{
|
|
|
|
config = mkIf (podman.enable && podman.${name}.enable) {
|
2024-08-21 21:18:54 +07:00
|
|
|
# Minecraft only autoupdates at startup
|
|
|
|
#
|
|
|
|
# To keep up with the update, restart the server at 4am everyday.
|
2024-08-18 16:19:29 +07:00
|
|
|
systemd =
|
2024-10-21 12:31:30 +07:00
|
|
|
let
|
|
|
|
serviceName = "podman-${name}";
|
|
|
|
in
|
2024-08-18 16:19:29 +07:00
|
|
|
{
|
|
|
|
tmpfiles.settings."${serviceName}-mount".${rootVolume}.d = {
|
|
|
|
group = config.profile.user.name;
|
|
|
|
mode = "0755";
|
|
|
|
user = config.profile.user.name;
|
|
|
|
};
|
|
|
|
|
|
|
|
services."${serviceName}-autorestart" = {
|
|
|
|
description = "Podman container ${name} autorestart";
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
2024-08-21 21:12:58 +07:00
|
|
|
ExecStart = "${pkgs.podman}/bin/podman restart ${name}";
|
2024-08-18 16:19:29 +07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
timers."${serviceName}-autorestart" = {
|
|
|
|
description = "Podman container ${name} autorestart";
|
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "*-*-* 04:00:00";
|
|
|
|
};
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
};
|
|
|
|
};
|
2024-07-20 18:46:31 +07:00
|
|
|
|
|
|
|
virtualisation.oci-containers.containers.${name} = {
|
|
|
|
inherit image;
|
|
|
|
hostname = name;
|
|
|
|
autoStart = true;
|
|
|
|
user = "${uid}:${gid}";
|
|
|
|
ports = [
|
|
|
|
# Java Edition Ports
|
2024-08-04 15:52:32 +07:00
|
|
|
"25565:25565/udp"
|
|
|
|
"25565:25565"
|
2024-07-20 18:46:31 +07:00
|
|
|
# Bedrock Edition Ports
|
|
|
|
"19132:19132/udp"
|
|
|
|
"19132:19132"
|
|
|
|
];
|
2024-10-21 12:31:30 +07:00
|
|
|
volumes = [ "${rootVolume}:/minecraft" ];
|
2024-07-20 18:46:31 +07:00
|
|
|
extraOptions = [
|
|
|
|
"--network=podman"
|
|
|
|
"--ip=${ip}"
|
|
|
|
];
|
|
|
|
labels = {
|
|
|
|
"io.containers.autoupdate" = "registry";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|