1 { config, lib, pkgs, ... }:
7 cfg = config.services.nexus;
13 enable = mkEnableOption "Sonatype Nexus3 OSS service";
15 package = lib.mkPackageOption pkgs "nexus" { };
17 jdkPackage = lib.mkPackageOption pkgs "openjdk8" { };
22 description = "User which runs Nexus3.";
28 description = "Group which runs Nexus3.";
33 default = "/var/lib/sonatype-work";
34 description = "Home directory of the Nexus3 instance.";
37 listenAddress = mkOption {
39 default = "127.0.0.1";
40 description = "Address to listen on.";
43 listenPort = mkOption {
46 description = "Port to listen on.";
54 -XX:MaxDirectMemorySize=2G
55 -XX:+UnlockDiagnosticVMOptions
58 -XX:LogFile=${cfg.home}/nexus3/log/jvm.log
59 -XX:-OmitStackTraceInFastThrow
60 -Djava.net.preferIPv4Stack=true
61 -Dkaraf.home=${cfg.package}
62 -Dkaraf.base=${cfg.package}
63 -Dkaraf.etc=${cfg.package}/etc/karaf
64 -Djava.util.logging.config.file=${cfg.package}/etc/karaf/java.util.logging.properties
65 -Dkaraf.data=${cfg.home}/nexus3
66 -Djava.io.tmpdir=${cfg.home}/nexus3/tmp
67 -Dkaraf.startLocalConsole=false
68 -Djava.endorsed.dirs=${cfg.package}/lib/endorsed
70 defaultText = literalExpression ''
74 -XX:MaxDirectMemorySize=2G
75 -XX:+UnlockDiagnosticVMOptions
78 -XX:LogFile=''${home}/nexus3/log/jvm.log
79 -XX:-OmitStackTraceInFastThrow
80 -Djava.net.preferIPv4Stack=true
81 -Dkaraf.home=''${package}
82 -Dkaraf.base=''${package}
83 -Dkaraf.etc=''${package}/etc/karaf
84 -Djava.util.logging.config.file=''${package}/etc/karaf/java.util.logging.properties
85 -Dkaraf.data=''${home}/nexus3
86 -Djava.io.tmpdir=''${home}/nexus3/tmp
87 -Dkaraf.startLocalConsole=false
88 -Djava.endorsed.dirs=''${package}/lib/endorsed
93 Options for the JVM written to `nexus.jvmopts`.
94 Please refer to the docs (https://help.sonatype.com/repomanager3/installation/configuring-the-runtime-environment)
95 for further information.
101 config = mkIf cfg.enable {
102 users.users.${cfg.user} = {
104 inherit (cfg) group home;
108 users.groups.${cfg.group} = { };
110 systemd.services.nexus = {
111 description = "Sonatype Nexus3";
113 wantedBy = [ "multi-user.target" ];
118 NEXUS_USER = cfg.user;
119 NEXUS_HOME = cfg.home;
121 INSTALL4J_JAVA_HOME = cfg.jdkPackage;
122 VM_OPTS_FILE = pkgs.writeText "nexus.vmoptions" cfg.jvmOpts;
126 mkdir -p ${cfg.home}/nexus3/etc
128 if [ ! -f ${cfg.home}/nexus3/etc/nexus.properties ]; then
129 echo "# Jetty section" > ${cfg.home}/nexus3/etc/nexus.properties
130 echo "application-port=${toString cfg.listenPort}" >> ${cfg.home}/nexus3/etc/nexus.properties
131 echo "application-host=${toString cfg.listenAddress}" >> ${cfg.home}/nexus3/etc/nexus.properties
133 sed 's/^application-port=.*/application-port=${toString cfg.listenPort}/' -i ${cfg.home}/nexus3/etc/nexus.properties
134 sed 's/^# application-port=.*/application-port=${toString cfg.listenPort}/' -i ${cfg.home}/nexus3/etc/nexus.properties
135 sed 's/^application-host=.*/application-host=${toString cfg.listenAddress}/' -i ${cfg.home}/nexus3/etc/nexus.properties
136 sed 's/^# application-host=.*/application-host=${toString cfg.listenAddress}/' -i ${cfg.home}/nexus3/etc/nexus.properties
140 script = "${cfg.package}/bin/nexus run";
146 LimitNOFILE = 102642;
151 meta.maintainers = with lib.maintainers; [ ironpinguin ];