-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ pkgs, ... }: | ||
{ | ||
imports = [ | ||
./msd.nix | ||
]; | ||
|
||
lib.pkgs = { | ||
authlib-injector = pkgs.fetchurl { | ||
url = "https://github.com/yushijinhun/authlib-injector/releases/download/v1.2.4/authlib-injector-1.2.4.jar"; | ||
hash = "sha256-eVsnbLQIVe0E3H/KvCptFQ3kYAtUKHWmUi5l9rJbyp8="; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ config, pkgs, ... }: | ||
let | ||
name = "modernskyblock"; | ||
serviceName = "minecraft-${name}"; | ||
directory = "minecraft/${name}"; | ||
stdin = "/run/${directory}/stdin"; | ||
|
||
# https://github.com/NixOS/nixpkgs/blob/6e62521155cd3b4cdf6b49ecacf63db2a0cacc73/nixos/modules/services/games/minecraft-server.nix#L25C3-L34C1 | ||
stopScript = pkgs.writeShellScript "minecraft-server-stop" '' | ||
echo stop > ${stdin} | ||
# Wait for the PID of the minecraft server to disappear before | ||
# returning, so systemd doesn't attempt to SIGKILL it. | ||
while kill -0 "$1" 2> /dev/null; do | ||
sleep 1s | ||
done | ||
''; | ||
|
||
in | ||
{ | ||
systemd.services.${serviceName} = { | ||
after = [ "systemd-networkd-wait-online.service" ]; | ||
description = "Minecraft Server (Modern Skyblock 3: Departed)"; | ||
requires = [ "${serviceName}.socket" ]; | ||
serviceConfig = rec { | ||
Type = "simple"; | ||
DynamicUser = true; | ||
StateDirectory = directory; | ||
WorkingDirectory = "%S/${directory}"; | ||
ExecStart = "${pkgs.jdk8}/bin/java -Xmx32G -Xms32G -javaagent:${config.lib.pkgs.authlib-injector}=https://hitmc.cc/api/yggdrasil -jar forge-1.12.2-14.23.5.2808-universal.jar nogui"; | ||
ExecStop = "${stopScript} $MAINPID"; | ||
Restart = "always"; | ||
StandardInput = "socket"; | ||
StandardOutput = "journal"; | ||
StandardError = "journal"; | ||
}; | ||
}; | ||
|
||
systemd.sockets.${serviceName} = { | ||
description = "Socket for the Minecraft Server (Modern Skyblock 3: Departed)"; | ||
wantedBy = [ "sockets.target" ]; | ||
socketConfig = { | ||
ListenFIFO = stdin; | ||
RemoveOnStop = true; | ||
FlushPending = true; | ||
}; | ||
}; | ||
} |