diff --git a/module/client.nix b/module/client.nix index 2b74343..5cfa617 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,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; diff --git a/module/server.nix b/module/server.nix index ec820af..1a5ff09 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,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;