2017-09-01 18:24:20 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.nexus;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.nexus = {
|
2017-11-29 22:37:05 +01:00
|
|
|
enable = mkEnableOption "Sonatype Nexus3 OSS service";
|
2017-09-01 18:24:20 +02:00
|
|
|
|
2018-06-13 05:54:32 +02:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.nexus;
|
|
|
|
description = "Package which runs Nexus3";
|
|
|
|
};
|
|
|
|
|
2017-09-01 18:24:20 +02:00
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "nexus";
|
|
|
|
description = "User which runs Nexus3.";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "nexus";
|
|
|
|
description = "Group which runs Nexus3.";
|
|
|
|
};
|
|
|
|
|
|
|
|
home = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/sonatype-work";
|
|
|
|
description = "Home directory of the Nexus3 instance.";
|
|
|
|
};
|
|
|
|
|
|
|
|
listenAddress = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
|
|
|
description = "Address to listen on.";
|
|
|
|
};
|
|
|
|
|
|
|
|
listenPort = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 8081;
|
|
|
|
description = "Port to listen on.";
|
|
|
|
};
|
2018-05-15 14:10:29 +02: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 05:54:32 +02: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 14:10:29 +02:00
|
|
|
-Dkaraf.data=${cfg.home}/nexus3
|
|
|
|
-Djava.io.tmpdir=${cfg.home}/nexus3/tmp
|
|
|
|
-Dkaraf.startLocalConsole=false
|
2019-10-28 21:33:16 +01:00
|
|
|
-Djava.endorsed.dirs=${cfg.package}/lib/endorsed
|
2018-05-15 14:10:29 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
description = ''
|
|
|
|
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 18:24:20 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2019-08-13 23:52:01 +02:00
|
|
|
users.users.${cfg.user} = {
|
2017-09-01 18:24:20 +02:00
|
|
|
isSystemUser = true;
|
|
|
|
group = cfg.group;
|
2019-02-24 15:21:24 +01:00
|
|
|
home = cfg.home;
|
|
|
|
createHome = true;
|
2017-09-01 18:24:20 +02:00
|
|
|
};
|
|
|
|
|
2019-08-13 23:52:01 +02:00
|
|
|
users.groups.${cfg.group} = {};
|
2017-09-01 18:24:20 +02:00
|
|
|
|
|
|
|
systemd.services.nexus = {
|
2017-11-29 22:37:05 +01:00
|
|
|
description = "Sonatype Nexus3";
|
2017-09-01 18:24:20 +02:00
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
path = [ cfg.home ];
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
NEXUS_USER = cfg.user;
|
|
|
|
NEXUS_HOME = cfg.home;
|
2018-05-15 14:10:29 +02:00
|
|
|
|
|
|
|
VM_OPTS_FILE = pkgs.writeText "nexus.vmoptions" cfg.jvmOpts;
|
2017-09-01 18:24:20 +02: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 14:10:29 +02: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 18:24:20 +02:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2018-06-13 05:54:32 +02:00
|
|
|
script = "${cfg.package}/bin/nexus run";
|
2017-09-01 18:24:20 +02:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
PrivateTmp = true;
|
|
|
|
LimitNOFILE = 102642;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-07-09 06:48:15 +02:00
|
|
|
meta.maintainers = with lib.maintainers; [ ironpinguin ];
|
2017-09-01 18:24:20 +02:00
|
|
|
}
|