System Gen143 @ 2026-03-19-20:01:56 by jonas@monolith
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
./services/gitea-instance.nix
|
||||
./services/gotify-instance.nix
|
||||
./services/kdeconnect.nix
|
||||
./services/minecraft-server
|
||||
./services/nextcloud-instance.nix
|
||||
./services/virt-manager.nix
|
||||
]
|
||||
|
||||
39
modules/services/minecraft-server/default.nix
Normal file
39
modules/services/minecraft-server/default.nix
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.hive.services.minecraft-server;
|
||||
|
||||
modpack = pkgs.callPackage ./loadCurseForge.nix {
|
||||
url = "https://mediafilez.forgecdn.net/files/7765/203/BMC3_Server_Pack_v44.zip";
|
||||
hash = "";
|
||||
};
|
||||
|
||||
mcVersion = modpack.variables.MINECRAFT_VERSION;
|
||||
loader = lib.toLower modpack.variables.MODLOADER;
|
||||
loaderVersion = modpack.variables.MODLOADER_VERSION;
|
||||
serverVersion = lib.replaceStrings ["."] ["_"] "${loader}-${mcVersion}";
|
||||
in {
|
||||
options.hive.services.minecraft-server = {
|
||||
enable = lib.mkEnableOption "Enable BMC3 server";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.minecraft-servers.servers.bmc3 =
|
||||
{
|
||||
enable = true;
|
||||
eula = true;
|
||||
}
|
||||
# Prevent download of modpack if not enabled
|
||||
// (lib.optionalAttrs cfg.enable {
|
||||
package = pkgs."${loader}Servers".${serverVersion}.override {inherit loaderVersion;};
|
||||
jvmOpts = modpack.variables.JAVA_ARGS;
|
||||
symlinks = {
|
||||
"mods" = modpack.mods;
|
||||
"config" = modpack.config;
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
36
modules/services/minecraft-server/loadCurseForge.nix
Normal file
36
modules/services/minecraft-server/loadCurseForge.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
url ? null,
|
||||
hash ? null,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
modpack = pkgs.fetchzip {
|
||||
inherit url hash;
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
variablesStr = builtins.readFile "${modpack}/variables.txt";
|
||||
variableLines =
|
||||
builtins.filter (l: l != "" && (lib.strings.elemAt (lib.stringToCharacters l) 0) != "#")
|
||||
(lib.strings.splitString "\n" variablesStr);
|
||||
|
||||
stripQuotes = s:
|
||||
if builtins.match "^\".*\"$" s != null
|
||||
then builtins.substring 1 (builtins.stringLength s - 2) s
|
||||
else s;
|
||||
|
||||
parseLine = line: let
|
||||
parts = lib.strings.splitString "=" line;
|
||||
in {
|
||||
name = builtins.elemAt parts 0;
|
||||
value = stripQuotes (builtins.concatStringsSep "=" (builtins.tail parts));
|
||||
};
|
||||
|
||||
variables = builtins.listToAttrs (map parseLine variableLines);
|
||||
in {
|
||||
inherit variables;
|
||||
root = modpack;
|
||||
mods = "${modpack}/mods";
|
||||
config = "${modpack}/config";
|
||||
}
|
||||
Reference in New Issue
Block a user