Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom java arguments #34

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions module/client.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf versionAtLeast;
inherit (lib.types) mkOptionType listOf path package singleLineStr bool;
inherit (lib.types) mkOptionType listOf path package singleLineStr bool str;
inherit (lib.options) mergeEqualOption mkOption;
inherit (lib.strings)
isStringLike hasSuffix makeLibraryPath concatStringsSep concatMapStringsSep
@@ -61,6 +61,17 @@ in {
description = "Whether using a declarative way to manage game files.";
default = true;
};
jvmArgs = mkOption {
type = listOf str;
description = "List of extra arguments to pass (as prefix) to Java launcher";
default = [];
};
appArgs = mkOption {
type = listOf str;
description = "List of extra arguments to pass (as postfix) to Java launcher";
default = [];
};


# Internal
libraries.java = mkOption {
@@ -152,6 +163,7 @@ in {
in ''
export LD_LIBRARY_PATH="${libPath}''${LD_LIBRARY_PATH:+':'}''${LD_LIBRARY_PATH:-}"
exec "${config.java}" \
${builtins.concatStringsSep " " config.jvmArgs} \
-Djava.library.path='${
concatMapStringsSep ":" (native: "${native}/lib")
config.libraries.native
@@ -168,7 +180,8 @@ in {
--username "$USER_NAME" \
--accessToken "$ACCESS_TOKEN" \
--userType "msa" \
"''${mcargs[@]}"
"''${mcargs[@]}" \
${builtins.concatStringsSep " " config.appArgs}
'';
};
launcher = writeShellScriptBin "minecraft" config.launchScript.finalText;
17 changes: 15 additions & 2 deletions module/server.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
let
inherit (lib.types) mkOptionType listOf package singleLineStr bool nullOr;
inherit (lib.types) mkOptionType listOf package singleLineStr bool nullOr str;
inherit (lib.options) mergeEqualOption mkOption;
inherit (lib.strings) isStringLike hasSuffix concatStringsSep optionalString;
inherit (pkgs) writeShellScriptBin;
@@ -36,6 +36,17 @@ in {
description = "Whether using a declarative way to manage game files.";
default = true;
};
jvmArgs = mkOption {
type = listOf str;
description = "List of extra arguments to pass (as prefix) to Java launcher";
default = [];
};
appArgs = mkOption {
type = listOf str;
description = "List of extra arguments to pass (as postfix) to Java launcher";
default = [];
};


# Internal
libraries.java = mkOption {
@@ -57,6 +68,7 @@ in {
config = {
launchScript.gameExecution = ''
exec "${config.java}" \
${builtins.concatStringsSep " " config.jvmArgs} \
-cp '${concatStringsSep ":" config.libraries.java}' \
${
optionalString (config.mods != [ ])
@@ -68,7 +80,8 @@ in {
else
"-jar '${config.mainJar}'"
} \
"''${runner_args[@]}"
"''${runner_args[@]}" \
${builtins.concatStringsSep " " config.appArgs}
'';
launcher =
writeShellScriptBin "minecraft-server" config.launchScript.finalText;