nixos/unifi: Switch command line args to a list

There's no functionality change here, but this makes it a bit more
convenient to add more args.
This commit is contained in:
Lucas Bergman 2023-11-09 19:41:47 +00:00
parent 2bc02c0383
commit 50ff8ff3f9

View File

@ -2,16 +2,17 @@
let let
cfg = config.services.unifi; cfg = config.services.unifi;
stateDir = "/var/lib/unifi"; stateDir = "/var/lib/unifi";
cmd = '' cmd = lib.escapeShellArgs ([ "@${cfg.jrePackage}/bin/java" "java" ]
@${cfg.jrePackage}/bin/java java \ ++ lib.optionals (lib.versionAtLeast (lib.getVersion cfg.jrePackage) "16") [
${lib.optionalString (lib.versionAtLeast (lib.getVersion cfg.jrePackage) "16") "--add-opens=java.base/java.lang=ALL-UNNAMED"
("--add-opens java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED " "--add-opens=java.base/java.time=ALL-UNNAMED"
+ "--add-opens java.base/sun.security.util=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED " "--add-opens=java.base/sun.security.util=ALL-UNNAMED"
+ "--add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED")} \ "--add-opens=java.base/java.io=ALL-UNNAMED"
${lib.optionalString (cfg.initialJavaHeapSize != null) "-Xms${(toString cfg.initialJavaHeapSize)}m"} \ "--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED"
${lib.optionalString (cfg.maximumJavaHeapSize != null) "-Xmx${(toString cfg.maximumJavaHeapSize)}m"} \ ]
-jar ${stateDir}/lib/ace.jar ++ (lib.optional (cfg.initialJavaHeapSize != null) "-Xms${(toString cfg.initialJavaHeapSize)}m")
''; ++ (lib.optional (cfg.maximumJavaHeapSize != null) "-Xmx${(toString cfg.maximumJavaHeapSize)}m")
++ [ "-jar" "${stateDir}/lib/ace.jar" ]);
in in
{ {
@ -122,8 +123,8 @@ in
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
ExecStart = "${(lib.removeSuffix "\n" cmd)} start"; ExecStart = "${cmd} start";
ExecStop = "${(lib.removeSuffix "\n" cmd)} stop"; ExecStop = "${cmd} stop";
Restart = "on-failure"; Restart = "on-failure";
TimeoutSec = "5min"; TimeoutSec = "5min";
User = "unifi"; User = "unifi";