From 837085cd2892fa687e8e2954ee84edbcb3c6e2bc Mon Sep 17 00:00:00 2001 From: "Alexandria P." Date: Sun, 17 Nov 2024 12:32:48 -0700 Subject: [PATCH 1/4] add custom java arguments --- module/client.nix | 11 +++++++++-- module/server.nix | 10 ++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/module/client.nix b/module/client.nix index 2b74343..8212e0c 100644 --- a/module/client.nix +++ b/module/client.nix @@ -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,12 @@ in { description = "Whether using a declarative way to manage game files."; default = true; }; + args = mkOption { + type = listOf str; + description = "List of extra arguments to pass to Java launcher"; + default = []; + }; + # Internal libraries.java = mkOption { @@ -168,7 +174,8 @@ in { --username "$USER_NAME" \ --accessToken "$ACCESS_TOKEN" \ --userType "msa" \ - "''${mcargs[@]}" + "''${mcargs[@]}" \ + ${builtins.concatStringsSep " " config.args} ''; }; launcher = writeShellScriptBin "minecraft" config.launchScript.finalText; diff --git a/module/server.nix b/module/server.nix index ec820af..25d3fd2 100644 --- a/module/server.nix +++ b/module/server.nix @@ -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,11 @@ in { description = "Whether using a declarative way to manage game files."; default = true; }; + args = mkOption { + type = listOf str; + description = "List of extra arguments to pass to Java launcher"; + default = []; + }; # Internal libraries.java = mkOption { @@ -68,7 +73,8 @@ in { else "-jar '${config.mainJar}'" } \ - "''${runner_args[@]}" + "''${runner_args[@]}" \ + ${builtins.concatStringsSep " " config.args} ''; launcher = writeShellScriptBin "minecraft-server" config.launchScript.finalText; From 5e82562ddb537eddbb6f892b73de79aadb1ea7ce Mon Sep 17 00:00:00 2001 From: "Alexandria P." Date: Sun, 17 Nov 2024 13:01:30 -0700 Subject: [PATCH 2/4] split into prefix & postfix arguments --- module/client.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/module/client.nix b/module/client.nix index 8212e0c..cbc870a 100644 --- a/module/client.nix +++ b/module/client.nix @@ -61,9 +61,14 @@ in { description = "Whether using a declarative way to manage game files."; default = true; }; - args = mkOption { + prefixArgs = mkOption { type = listOf str; - description = "List of extra arguments to pass to Java launcher"; + description = "List of extra arguments to pass (as prefix) to Java launcher"; + default = []; + }; + postfixArgs = mkOption { + type = listOf str; + description = "List of extra arguments to pass (as postfix) to Java launcher"; default = []; }; @@ -158,6 +163,7 @@ in { in '' export LD_LIBRARY_PATH="${libPath}''${LD_LIBRARY_PATH:+':'}''${LD_LIBRARY_PATH:-}" exec "${config.java}" \ + ${builtins.concatStringsSep " " config.prefixArgs} \ -Djava.library.path='${ concatMapStringsSep ":" (native: "${native}/lib") config.libraries.native @@ -175,7 +181,7 @@ in { --accessToken "$ACCESS_TOKEN" \ --userType "msa" \ "''${mcargs[@]}" \ - ${builtins.concatStringsSep " " config.args} + ${builtins.concatStringsSep " " config.postfixArgs} ''; }; launcher = writeShellScriptBin "minecraft" config.launchScript.finalText; From 0192bcbc553a44cf066659169123513122435455 Mon Sep 17 00:00:00 2001 From: "Alexandria P." Date: Sun, 17 Nov 2024 13:09:14 -0700 Subject: [PATCH 3/4] split into prefix & postfix arguments --- module/server.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/module/server.nix b/module/server.nix index 25d3fd2..b644aae 100644 --- a/module/server.nix +++ b/module/server.nix @@ -36,11 +36,17 @@ in { description = "Whether using a declarative way to manage game files."; default = true; }; - args = mkOption { + prefixArgs = mkOption { type = listOf str; - description = "List of extra arguments to pass to Java launcher"; + description = "List of extra arguments to pass (as prefix) to Java launcher"; default = []; }; + postfixArgs = mkOption { + type = listOf str; + description = "List of extra arguments to pass (as postfix) to Java launcher"; + default = []; + }; + # Internal libraries.java = mkOption { @@ -62,6 +68,7 @@ in { config = { launchScript.gameExecution = '' exec "${config.java}" \ + ${builtins.concatStringsSep " " config.prefixArgs} \ -cp '${concatStringsSep ":" config.libraries.java}' \ ${ optionalString (config.mods != [ ]) @@ -74,7 +81,7 @@ in { "-jar '${config.mainJar}'" } \ "''${runner_args[@]}" \ - ${builtins.concatStringsSep " " config.args} + ${builtins.concatStringsSep " " config.postfixArgs} ''; launcher = writeShellScriptBin "minecraft-server" config.launchScript.finalText; From dba2663fccf7d304d6dda018790b9b58ddc6296a Mon Sep 17 00:00:00 2001 From: "Alexandria P." Date: Tue, 19 Nov 2024 13:04:40 -0700 Subject: [PATCH 4/4] change names to be more meaningful --- module/client.nix | 8 ++++---- module/server.nix | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/module/client.nix b/module/client.nix index cbc870a..5cfa617 100644 --- a/module/client.nix +++ b/module/client.nix @@ -61,12 +61,12 @@ in { description = "Whether using a declarative way to manage game files."; default = true; }; - prefixArgs = mkOption { + jvmArgs = mkOption { type = listOf str; description = "List of extra arguments to pass (as prefix) to Java launcher"; default = []; }; - postfixArgs = mkOption { + appArgs = mkOption { type = listOf str; description = "List of extra arguments to pass (as postfix) to Java launcher"; default = []; @@ -163,7 +163,7 @@ in { in '' export LD_LIBRARY_PATH="${libPath}''${LD_LIBRARY_PATH:+':'}''${LD_LIBRARY_PATH:-}" exec "${config.java}" \ - ${builtins.concatStringsSep " " config.prefixArgs} \ + ${builtins.concatStringsSep " " config.jvmArgs} \ -Djava.library.path='${ concatMapStringsSep ":" (native: "${native}/lib") config.libraries.native @@ -181,7 +181,7 @@ in { --accessToken "$ACCESS_TOKEN" \ --userType "msa" \ "''${mcargs[@]}" \ - ${builtins.concatStringsSep " " config.postfixArgs} + ${builtins.concatStringsSep " " config.appArgs} ''; }; launcher = writeShellScriptBin "minecraft" config.launchScript.finalText; diff --git a/module/server.nix b/module/server.nix index b644aae..1a5ff09 100644 --- a/module/server.nix +++ b/module/server.nix @@ -36,12 +36,12 @@ in { description = "Whether using a declarative way to manage game files."; default = true; }; - prefixArgs = mkOption { + jvmArgs = mkOption { type = listOf str; description = "List of extra arguments to pass (as prefix) to Java launcher"; default = []; }; - postfixArgs = mkOption { + appArgs = mkOption { type = listOf str; description = "List of extra arguments to pass (as postfix) to Java launcher"; default = []; @@ -68,7 +68,7 @@ in { config = { launchScript.gameExecution = '' exec "${config.java}" \ - ${builtins.concatStringsSep " " config.prefixArgs} \ + ${builtins.concatStringsSep " " config.jvmArgs} \ -cp '${concatStringsSep ":" config.libraries.java}' \ ${ optionalString (config.mods != [ ]) @@ -81,7 +81,7 @@ in { "-jar '${config.mainJar}'" } \ "''${runner_args[@]}" \ - ${builtins.concatStringsSep " " config.postfixArgs} + ${builtins.concatStringsSep " " config.appArgs} ''; launcher = writeShellScriptBin "minecraft-server" config.launchScript.finalText;