2017-09-01 16:24:20 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.nexus;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.nexus = {
|
2017-11-29 21:37:05 +00:00
|
|
|
enable = mkEnableOption "Sonatype Nexus3 OSS service";
|
2017-09-01 16:24:20 +00:00
|
|
|
|
2018-06-13 03:54:32 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.nexus;
|
2021-10-03 16:06:03 +00:00
|
|
|
defaultText = literalExpression "pkgs.nexus";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Package which runs Nexus3";
|
2018-06-13 03:54:32 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 16:24:20 +00:00
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "nexus";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "User which runs Nexus3.";
|
2017-09-01 16:24:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "nexus";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Group which runs Nexus3.";
|
2017-09-01 16:24:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
home = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/sonatype-work";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Home directory of the Nexus3 instance.";
|
2017-09-01 16:24:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
listenAddress = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Address to listen on.";
|
2017-09-01 16:24:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
listenPort = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 8081;
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Port to listen on.";
|
2017-09-01 16:24:20 +00:00
|
|
|
};
|
2018-05-15 12:10:29 +00:00
|
|
|
|
|
|
|
jvmOpts = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = ''
|
|
|
|
-Xms1200M
|
|
|
|
-Xmx1200M
|
|
|
|
-XX:MaxDirectMemorySize=2G
|
|
|
|
-XX:+UnlockDiagnosticVMOptions
|
|
|
|
-XX:+UnsyncloadClass
|
|
|
|
-XX:+LogVMOutput
|
|
|
|
-XX:LogFile=${cfg.home}/nexus3/log/jvm.log
|
|
|
|
-XX:-OmitStackTraceInFastThrow
|
|
|
|
-Djava.net.preferIPv4Stack=true
|
2018-06-13 03:54:32 +00:00
|
|
|
-Dkaraf.home=${cfg.package}
|
|
|
|
-Dkaraf.base=${cfg.package}
|
|
|
|
-Dkaraf.etc=${cfg.package}/etc/karaf
|
|
|
|
-Djava.util.logging.config.file=${cfg.package}/etc/karaf/java.util.logging.properties
|
2018-05-15 12:10:29 +00:00
|
|
|
-Dkaraf.data=${cfg.home}/nexus3
|
|
|
|
-Djava.io.tmpdir=${cfg.home}/nexus3/tmp
|
|
|
|
-Dkaraf.startLocalConsole=false
|
2019-10-28 20:33:16 +00:00
|
|
|
-Djava.endorsed.dirs=${cfg.package}/lib/endorsed
|
2018-05-15 12:10:29 +00:00
|
|
|
'';
|
2021-10-03 16:06:03 +00:00
|
|
|
defaultText = literalExpression ''
|
|
|
|
'''
|
|
|
|
-Xms1200M
|
|
|
|
-Xmx1200M
|
|
|
|
-XX:MaxDirectMemorySize=2G
|
|
|
|
-XX:+UnlockDiagnosticVMOptions
|
|
|
|
-XX:+UnsyncloadClass
|
|
|
|
-XX:+LogVMOutput
|
|
|
|
-XX:LogFile=''${home}/nexus3/log/jvm.log
|
|
|
|
-XX:-OmitStackTraceInFastThrow
|
|
|
|
-Djava.net.preferIPv4Stack=true
|
|
|
|
-Dkaraf.home=''${package}
|
|
|
|
-Dkaraf.base=''${package}
|
|
|
|
-Dkaraf.etc=''${package}/etc/karaf
|
|
|
|
-Djava.util.logging.config.file=''${package}/etc/karaf/java.util.logging.properties
|
|
|
|
-Dkaraf.data=''${home}/nexus3
|
|
|
|
-Djava.io.tmpdir=''${home}/nexus3/tmp
|
|
|
|
-Dkaraf.startLocalConsole=false
|
|
|
|
-Djava.endorsed.dirs=''${package}/lib/endorsed
|
|
|
|
'''
|
|
|
|
'';
|
2018-05-15 12:10:29 +00:00
|
|
|
|
2022-08-14 07:03:30 +00:00
|
|
|
description = lib.mdDoc ''
|
2018-05-15 12:10:29 +00:00
|
|
|
Options for the JVM written to `nexus.jvmopts`.
|
|
|
|
Please refer to the docs (https://help.sonatype.com/repomanager3/installation/configuring-the-runtime-environment)
|
|
|
|
for further information.
|
|
|
|
'';
|
|
|
|
};
|
2017-09-01 16:24:20 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2019-08-13 21:52:01 +00:00
|
|
|
users.users.${cfg.user} = {
|
2017-09-01 16:24:20 +00:00
|
|
|
isSystemUser = true;
|
|
|
|
group = cfg.group;
|
2019-02-24 14:21:24 +00:00
|
|
|
home = cfg.home;
|
|
|
|
createHome = true;
|
2017-09-01 16:24:20 +00:00
|
|
|
};
|
|
|
|
|
2019-08-13 21:52:01 +00:00
|
|
|
users.groups.${cfg.group} = {};
|
2017-09-01 16:24:20 +00:00
|
|
|
|
|
|
|
systemd.services.nexus = {
|
2017-11-29 21:37:05 +00:00
|
|
|
description = "Sonatype Nexus3";
|
2017-09-01 16:24:20 +00:00
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
path = [ cfg.home ];
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
NEXUS_USER = cfg.user;
|
|
|
|
NEXUS_HOME = cfg.home;
|
2018-05-15 12:10:29 +00:00
|
|
|
|
|
|
|
VM_OPTS_FILE = pkgs.writeText "nexus.vmoptions" cfg.jvmOpts;
|
2017-09-01 16:24:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
preStart = ''
|
|
|
|
mkdir -p ${cfg.home}/nexus3/etc
|
|
|
|
|
|
|
|
if [ ! -f ${cfg.home}/nexus3/etc/nexus.properties ]; then
|
|
|
|
echo "# Jetty section" > ${cfg.home}/nexus3/etc/nexus.properties
|
|
|
|
echo "application-port=${toString cfg.listenPort}" >> ${cfg.home}/nexus3/etc/nexus.properties
|
|
|
|
echo "application-host=${toString cfg.listenAddress}" >> ${cfg.home}/nexus3/etc/nexus.properties
|
|
|
|
else
|
2018-05-15 12:10:29 +00:00
|
|
|
sed 's/^application-port=.*/application-port=${toString cfg.listenPort}/' -i ${cfg.home}/nexus3/etc/nexus.properties
|
|
|
|
sed 's/^# application-port=.*/application-port=${toString cfg.listenPort}/' -i ${cfg.home}/nexus3/etc/nexus.properties
|
|
|
|
sed 's/^application-host=.*/application-host=${toString cfg.listenAddress}/' -i ${cfg.home}/nexus3/etc/nexus.properties
|
|
|
|
sed 's/^# application-host=.*/application-host=${toString cfg.listenAddress}/' -i ${cfg.home}/nexus3/etc/nexus.properties
|
2017-09-01 16:24:20 +00:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2018-06-13 03:54:32 +00:00
|
|
|
script = "${cfg.package}/bin/nexus run";
|
2017-09-01 16:24:20 +00:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
PrivateTmp = true;
|
|
|
|
LimitNOFILE = 102642;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-07-09 04:48:15 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ ironpinguin ];
|
2017-09-01 16:24:20 +00:00
|
|
|
}
|