Add FTB integrations

Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
Magic_RB 2023-07-20 12:52:48 +02:00
parent bd556bcc11
commit e2fc3e885e
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E
7 changed files with 160 additions and 6 deletions

View file

@ -73,6 +73,7 @@
nixng/containers/syncthing nixng/containers/syncthing
nixng/containers/minecraft/vanilla nixng/containers/minecraft/vanilla
nixng/containers/minecraft/ftb-infinity nixng/containers/minecraft/ftb-infinity
nixng/containers/minecraft/ftb-integrations
overlays/udp-over-tcp.nix overlays/udp-over-tcp.nix
overlays/emacsclient-remote overlays/emacsclient-remote

View file

@ -3,7 +3,8 @@ let
inherit (lib) inherit (lib)
concatStringsSep concatStringsSep
getExe getExe
flip; flip
singleton;
combineWines = wines: combineWines = wines:
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
@ -58,7 +59,20 @@ in
}; };
home.packages = with pkgs; [ home.packages = with pkgs; [
prismlauncher (prismlauncher.override {
jdks = with pkgs; [
jdk8
jdk11
jdk17
];
prismlauncher-unwrapped =
(prismlauncher-unwrapped.overrideAttrs (old: {
patches = singleton (pkgs.fetchurl {
url = "https://github.com/PrismLauncher/PrismLauncher/commit/603b38fa46dc61c0c5ae10a3754bcacb0201d881.diff";
sha256 = "sha256-Q/WkDVIvlYu6lkRPjoYZOUif0TPUT6Mmxd1JR4pgdLI=";
});
}));
})
dejavu_fonts dejavu_fonts
alacritty alacritty

View file

@ -0,0 +1,30 @@
{ inputs, ... }:
{
flake.nixngConfigurations.minecraft-ftb-integrations = inputs.nixng.nglib.makeSystem {
system = "x86_64-linux";
name = "nixng-minecraft";
inherit (inputs) nixpkgs;
config =
{ pkgs, lib, ... }:
{
disabledModules = [ "${inputs.nixng}/modules/services/minecraft.nix" ];
imports = [ ../../../modules/minecraft-forge.nix ../../../modules/minecraft.nix ];
dumb-init = {
enable = true;
type.services = {};
};
services.minecraft.forge = {
enable = true;
modpackId = 107;
versionId = 6572;
modpacksChHash = "sha256-YZATEoypF+H00KuJAOdsk1Kw1aWPS1y803GKGi7Tv7Y=";
javaPackage = pkgs.jdk11;
eulaAccept = true;
};
};
};
}

View file

@ -19,6 +19,11 @@ in
type = types.str; type = types.str;
}; };
javaPackage = mkOption {
type = types.package;
default = pkgs.jdk17;
};
serverPackage = mkOption { serverPackage = mkOption {
type = types.package; type = types.package;
readOnly = true; readOnly = true;
@ -36,6 +41,11 @@ in
type = with types; listOf str; type = with types; listOf str;
default = []; default = [];
}; };
extraFixup = mkOption {
type = types.lines;
default = "";
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -61,12 +71,18 @@ in
''; '';
installPhase = '' installPhase = ''
./modpacks.ch ${toString cfg.modpackId} ${toString cfg.versionId} --auto --nojava --path $out mkdir bin
ln -s ${pkgs.writeShellScript "noop" ''echo "cd $PWD ; java $@" > install-forge''} bin/java
export PATH=$PWD/bin:$PATH
./modpacks.ch ${toString cfg.modpackId} ${toString cfg.versionId} --nojava --path $out --verbose
''; '';
fixupPhase = '' fixupPhase = ''
# delete useless non-reproducible data that we really don't need. A less "shotgun" cleaning is possible # delete useless non-reproducible data that we really don't need. A less "shotgun" cleaning is possible
rm $out/version.json rm $out/version.json
${cfg.extraFixup}
''; '';
}; };
in in
@ -80,7 +96,7 @@ in
mkdir -p $out/bin mkdir -p $out/bin
cp ${pkgs.writeShellScript "server.sh" '' cp ${pkgs.writeShellScript "server.sh" ''
export PATH=${makeBinPath (with pkgs; [ coreutils findutils bash ])}:$PATH export PATH=${makeBinPath (with pkgs; [ coreutils findutils bash cfg.javaPackage ])}:$PATH
export _path=$PWD export _path=$PWD
echo $0 echo $0
@ -133,9 +149,11 @@ in
find ${forgeFod} -type f -printf '%P\n' | tr '\n' '\0' | xargs -0 -I {} sh -c 'linkFile "$1"' sh {} # mkdir -p "$_path/$(dirname "$1")" ; ln -s "${forgeFod}/$1" "$_path/$1" find ${forgeFod} -type f -printf '%P\n' | tr '\n' '\0' | xargs -0 -I {} sh -c 'linkFile "$1"' sh {} # mkdir -p "$_path/$(dirname "$1")" ; ln -s "${forgeFod}/$1" "$_path/$1"
ln -s ${pkgs.writeShellScript "start.sh" '' ln -s ${pkgs.writeShellScript "start.sh" ''
${lib.getExe pkgs.jdk8} $(cat ${forgeFod}/start.sh | grep -e "java" -e jar | sed 's/^"java" \(.*\) -jar .*$/\1/') "$@" -jar forge-*.jar ${lib.getExe cfg.javaPackage} $(cat ${forgeFod}/start.sh | grep -e "java" -e jar | sed 's/^"java" \(.*\) -jar .*$/\1/') "$@" -jar forge-*.jar
''} $_path/start.sh ''} $_path/start.sh
# [ -f $_path/install-forge ] && bash install-forge
$_path/start.sh $_path/start.sh
''} $out/bin/server ''} $out/bin/server
''; '';
@ -148,7 +166,7 @@ in
mkdir -p /var/lib/minecraft/forge mkdir -p /var/lib/minecraft/forge
cd /var/lib/minecraft/forge cd /var/lib/minecraft/forge
echo "eula=true" > eula.txt echo "eula=true" > eula.txt
${cfg.serverPackage}/bin/server ${concatMapStringsSep " " (x: ''"${x}"'') cfg.extraJavaArguments} ${pkgs.bash}/bin/bash -x ${cfg.serverPackage}/bin/server ${concatMapStringsSep " " (x: ''"${x}"'') cfg.extraJavaArguments}
''; '';
enabled = true; enabled = true;
}; };

View file

@ -0,0 +1,24 @@
{ config', pkgs, elib, vars, ... }:
let
inherit (elib)
nfsVolume
nomadJob;
in
{
resource."nomad_volume"."minecraft-ftb-integrations" = nfsVolume {
access_mode = "single-node-writer";
volume_name = "minecraft-ftb-integrations";
server = "blowhole.hosts.in.redalder.org";
share = "/mnt/kyle/infrastructure/minecraft/ftb-integrations";
mount_flags = [ "hard" "vers=4.2" "rsize=131072" "wsize=131072" "async" ];
};
resource."nomad_job"."minecraft-ftb-integrations" = nomadJob {
jobspec = ./job.hcl;
vars = {
flake_ref = "${vars.flake_host}?rev=${vars.flake_rev}&ref=${vars.flake_ref}";
flake_sha = vars.flake_sha;
store_path = config'.flake.nixngConfigurations.minecraft-ftb-integrations.config.system.build.toplevel;
};
};
}

View file

@ -0,0 +1,62 @@
variable "flake_ref" {
type = string
}
variable "flake_sha" {
type = string
}
variable "store_path" {
type = string
}
job "minecraft-ftb-integrations" {
datacenters = [ "homelab-1" ]
type = "service"
group "minecraft-ftb-integrations" {
count = 1
volume "minecraft-ftb-integrations" {
type = "csi"
source = "minecraft-ftb-integrations"
read_only = false
attachment_mode = "file-system"
access_mode = "single-node-writer"
}
network {
mode = "bridge"
port "minecraft" {
static = 25562
to = 25565
}
}
task "minecraft-ftb-integrations" {
driver = "docker"
config {
nix_flake_ref = "${var.flake_ref}#nixngConfigurations.minecraft-ftb-integrations.config.system.build.toplevel"
nix_flake_sha = var.flake_sha
nix_flake_store_path = var.store_path
entrypoint = [ "init" ]
ports = ["minecraft"]
}
resources {
cpu = 4096
memory = 6500
}
volume_mount {
volume = "minecraft-ftb-integrations"
destination = "/var/lib/minecraft/forge"
read_only = false
}
}
}
}

View file

@ -111,6 +111,11 @@ in
source = ./containers/minecraft/ftb-infinity; source = ./containers/minecraft/ftb-infinity;
}; };
module."minecraft-ftb-integrations" = elib.terraformModule {
name = "nfs-csi";
source = ./containers/minecraft/ftb-integrations;
};
module."altra" = elib.terraformModule { module."altra" = elib.terraformModule {
name = "altra"; name = "altra";
source = ./altra.nix; source = ./altra.nix;