3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/modules/services/web-apps/nexus.nix
pennae 2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00

157 lines
4.7 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.nexus;
in
{
options = {
services.nexus = {
enable = mkEnableOption "Sonatype Nexus3 OSS service";
package = mkOption {
type = types.package;
default = pkgs.nexus;
defaultText = literalExpression "pkgs.nexus";
description = lib.mdDoc "Package which runs Nexus3";
};
user = mkOption {
type = types.str;
default = "nexus";
description = lib.mdDoc "User which runs Nexus3.";
};
group = mkOption {
type = types.str;
default = "nexus";
description = lib.mdDoc "Group which runs Nexus3.";
};
home = mkOption {
type = types.str;
default = "/var/lib/sonatype-work";
description = lib.mdDoc "Home directory of the Nexus3 instance.";
};
listenAddress = mkOption {
type = types.str;
default = "127.0.0.1";
description = lib.mdDoc "Address to listen on.";
};
listenPort = mkOption {
type = types.int;
default = 8081;
description = lib.mdDoc "Port to listen on.";
};
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
-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
-Dkaraf.data=${cfg.home}/nexus3
-Djava.io.tmpdir=${cfg.home}/nexus3/tmp
-Dkaraf.startLocalConsole=false
-Djava.endorsed.dirs=${cfg.package}/lib/endorsed
'';
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
'''
'';
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.
'';
};
};
};
config = mkIf cfg.enable {
users.users.${cfg.user} = {
isSystemUser = true;
group = cfg.group;
home = cfg.home;
createHome = true;
};
users.groups.${cfg.group} = {};
systemd.services.nexus = {
description = "Sonatype Nexus3";
wantedBy = [ "multi-user.target" ];
path = [ cfg.home ];
environment = {
NEXUS_USER = cfg.user;
NEXUS_HOME = cfg.home;
VM_OPTS_FILE = pkgs.writeText "nexus.vmoptions" cfg.jvmOpts;
};
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
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
fi
'';
script = "${cfg.package}/bin/nexus run";
serviceConfig = {
User = cfg.user;
Group = cfg.group;
PrivateTmp = true;
LimitNOFILE = 102642;
};
};
};
meta.maintainers = with lib.maintainers; [ ironpinguin ];
}