176 lines
5.5 KiB
Nix
176 lines
5.5 KiB
Nix
{
|
|
description = "NomiFactory harder config — modified modpack";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
|
};
|
|
|
|
outputs =
|
|
{ self, nixpkgs }:
|
|
let
|
|
system = "x86_64-linux";
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
sources = import ./sources.nix;
|
|
|
|
# base Nomi
|
|
base-server = pkgs.fetchurl sources.nomi-server;
|
|
base-client = pkgs.fetchurl sources.nomi-client;
|
|
|
|
# additional mods
|
|
hardcore-darkness = {
|
|
src = pkgs.fetchurl sources.hardcore-darkness;
|
|
jar = "HardcoreDarkness.jar";
|
|
};
|
|
simple-login = {
|
|
src = pkgs.fetchurl sources.simple-login;
|
|
jar = "SimpleLogin.jar";
|
|
};
|
|
|
|
buildSide =
|
|
{
|
|
name,
|
|
base,
|
|
extraMods,
|
|
}:
|
|
let
|
|
modsDir = if name == "client" then "overrides/mods" else "mods";
|
|
commonDir = ./patches/common;
|
|
prefix = if name == "client" then "overrides/" else "";
|
|
sideDir = toString ./patches + "/${name}";
|
|
ae-fix =
|
|
if name == "server" then
|
|
''
|
|
# Strip AE2 coremod registration from the jar — bansoukou already provides
|
|
# patched classes. The original jar's AE2ELTransformer would add
|
|
# readItemStack_ae2el_old to PacketBuffer, but bansoukou's patched
|
|
# PacketBuffer already has it, causing Duplicate method name error.
|
|
# We keep the jar for mod registration but remove the FMLCorePlugin
|
|
# manifest entry so the coremod (and its transformer) doesn't load.
|
|
mkdir -p mods/ae2-uel-v0.56.7
|
|
cd mods/ae2-uel-v0.56.7
|
|
unzip -qo ../ae2-uel-v0.56.7.jar
|
|
sed -i '/^FMLCorePlugin:/d' META-INF/MANIFEST.MF
|
|
zip -qr ../ae2-uel-v0.56.7.jar .
|
|
cd ../..
|
|
rm -rf mods/ae2-uel-v0.56.7
|
|
''
|
|
else
|
|
"";
|
|
in
|
|
pkgs.runCommand "nomifactory-harder-${name}"
|
|
{
|
|
nativeBuildInputs = with pkgs; [
|
|
unzip
|
|
zip
|
|
patch
|
|
];
|
|
allowSubstitutes = false;
|
|
}
|
|
''
|
|
mkdir staging
|
|
cd staging
|
|
unzip -q ${base}
|
|
|
|
# Normalize line endings before patching (some configs are CRLF)
|
|
find . -type f \( -name '*.cfg' -o -name '*.properties' -o -name '*.xml' -o -name '*.zs' -o -name '*.json' \) \
|
|
-exec sed -i 's/\r$//' {} \;
|
|
|
|
# Apply patches and overlays from common/
|
|
if [ -d "${commonDir}" ]; then
|
|
for p in $(find "${commonDir}" -name '*.patch'); do
|
|
rel="''${p#${commonDir}/}"
|
|
target="${prefix}''${rel%.patch}"
|
|
patch -p0 -l "$target" < "$p"
|
|
done
|
|
for f in $(find "${commonDir}" -type f ! -name '*.patch' -size +0c); do
|
|
rel="''${f#${commonDir}/}"
|
|
target="${prefix}$rel"
|
|
mkdir -p "$(dirname "$target")"
|
|
cp "$f" "$target"
|
|
done
|
|
fi
|
|
|
|
# Apply patches and overlays from side-specific dir (if present)
|
|
if [ -d "${sideDir}" ]; then
|
|
for p in $(find "${sideDir}" -name '*.patch'); do
|
|
rel="''${p#${sideDir}/}"
|
|
target="''${rel%.patch}"
|
|
patch -p0 -l "$target" < "$p"
|
|
done
|
|
for f in $(find "${sideDir}" -type f ! -name '*.patch' -size +0c); do
|
|
rel="''${f#${sideDir}/}"
|
|
mkdir -p "$(dirname "$rel")"
|
|
cp "$f" "$rel"
|
|
done
|
|
fi
|
|
|
|
${ae-fix}
|
|
|
|
# Inject extra mod jars into the correct directory for this side
|
|
mkdir -p "${modsDir}"
|
|
${builtins.concatStringsSep "\n" (map (m: "cp ${m.src} \"${modsDir}/${m.jar}\"") extraMods)}
|
|
|
|
# Repack (zip auto-appends .zip; fix if it does)
|
|
zip -qr "$out" .
|
|
[ -f "$out.zip" ] && mv "$out.zip" "$out" || true
|
|
'';
|
|
|
|
launch-server = pkgs.writeShellScript "nomifactory-harder-server" ''
|
|
set -euo pipefail
|
|
DATA_DIR="''${1:-./nomifactory-harder-data}"
|
|
|
|
${pkgs.coreutils}/bin/mkdir -p "$DATA_DIR"
|
|
${pkgs.coreutils}/bin/echo "Extracting server pack to $DATA_DIR ..."
|
|
${pkgs.unzip}/bin/unzip -n ${self.packages.${system}.server} -d "$DATA_DIR"
|
|
|
|
cd "$DATA_DIR"
|
|
export PATH="${pkgs.jre8}/bin:$PATH"
|
|
${pkgs.coreutils}/bin/chmod +x launch.sh
|
|
${pkgs.bash}/bin/bash launch.sh
|
|
'';
|
|
in
|
|
{
|
|
packages.${system} = {
|
|
server = buildSide {
|
|
name = "server";
|
|
base = base-server;
|
|
extraMods = [
|
|
simple-login
|
|
];
|
|
};
|
|
|
|
client = buildSide {
|
|
name = "client";
|
|
base = base-client;
|
|
extraMods = [
|
|
hardcore-darkness
|
|
simple-login
|
|
];
|
|
};
|
|
|
|
default = self.packages.${system}.server;
|
|
|
|
server-oci = pkgs.dockerTools.buildImage {
|
|
name = "git.dzuchun.ing/dzu/nomisuffory";
|
|
tag = "main";
|
|
|
|
copyToRoot = pkgs.writeShellScriptBin "entrypoint" ''
|
|
exec ${launch-server} /srv
|
|
'';
|
|
|
|
config = {
|
|
Entrypoint = [ "/bin/entrypoint" ];
|
|
WorkingDir = "/srv";
|
|
};
|
|
};
|
|
};
|
|
|
|
apps.${system} = {
|
|
server = {
|
|
type = "app";
|
|
program = "${launch-server}";
|
|
};
|
|
};
|
|
};
|
|
}
|