nexus: fix setup and nixos test (#40522)
The original `nexus` derivation required `/run/sonatype-work/nexus3` which explicitly depended on the NixOS path structure. This would break `nexus` for everyone using `nixpkgs` on a non-NixOS system, additionally the module never created `/run/sonatype-work`, so the systemd unit created in `services.nexus` fails as well. The issue wasn't actively known as the `nixos/nexus` test wasn't registered in Hydra (see #40257). This patch contains the following changes: * Adds `tests.nexus` to `release.nix` to run the test on Hydra. * Makes JVM parameters configurable: by default all JVM options were located in `result/bin/nexus.vmoptions` which made it quite hard to patch these parameters. Now it's possible to override all parameters by running `VM_OPTS_FILE=custom-nexus.vmoptions ./result/bin/nexus run` (after patching the `nexus` shell script), additionally it's possible to override these parameters with `services.nexus.vmoptions`. * Bumped Nexus from 3.5.1 to 3.11.0 * Run the `nexus` test on Hydra with `callTest` in `nixos/release.nix`, furthermore the test checks if the UI is available on the specified port. * Added myself as maintainer for the NixOS test and the package to have some more people in case of further breakage. * Added sufficient disk space to the `nexus` test, otherwise the service fails with the following errors: ``` com.orientechnologies.orient.core.exception.ODatabaseException: Cannot create database 'accesslog' com.orientechnologies.orient.core.exception.OLowDiskSpaceException: Error occurred while executing a write operation to database 'accesslog' due to limited free space on the disk (242 MB). The database is now working in read-only mode. Please close the database (or stop OrientDB), make room on your hard drive and then reopen the database. The minimal required space is 256 MB. Required space is now set to 256MB (you can change it by setting parameter storage.diskCache.diskFreeSpaceLimit) . ``` /cc @ironpinguin @xeji
This commit is contained in:
parent
640b6359ae
commit
91365cd23a
|
@ -42,6 +42,34 @@ in
|
||||||
default = 8081;
|
default = 8081;
|
||||||
description = "Port to listen on.";
|
description = "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=${pkgs.nexus}
|
||||||
|
-Dkaraf.base=${pkgs.nexus}
|
||||||
|
-Dkaraf.etc=${pkgs.nexus}/etc/karaf
|
||||||
|
-Djava.util.logging.config.file=${pkgs.nexus}/etc/karaf/java.util.logging.properties
|
||||||
|
-Dkaraf.data=${cfg.home}/nexus3
|
||||||
|
-Djava.io.tmpdir=${cfg.home}/nexus3/tmp
|
||||||
|
-Dkaraf.startLocalConsole=false
|
||||||
|
'';
|
||||||
|
|
||||||
|
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.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,13 +91,13 @@ in
|
||||||
environment = {
|
environment = {
|
||||||
NEXUS_USER = cfg.user;
|
NEXUS_USER = cfg.user;
|
||||||
NEXUS_HOME = cfg.home;
|
NEXUS_HOME = cfg.home;
|
||||||
|
|
||||||
|
VM_OPTS_FILE = pkgs.writeText "nexus.vmoptions" cfg.jvmOpts;
|
||||||
};
|
};
|
||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -p ${cfg.home}/nexus3/etc
|
mkdir -p ${cfg.home}/nexus3/etc
|
||||||
|
|
||||||
ln -sf ${cfg.home} /run/sonatype-work
|
|
||||||
|
|
||||||
chown -R ${cfg.user}:${cfg.group} ${cfg.home}
|
chown -R ${cfg.user}:${cfg.group} ${cfg.home}
|
||||||
|
|
||||||
if [ ! -f ${cfg.home}/nexus3/etc/nexus.properties ]; then
|
if [ ! -f ${cfg.home}/nexus3/etc/nexus.properties ]; then
|
||||||
|
@ -77,10 +105,10 @@ in
|
||||||
echo "application-port=${toString cfg.listenPort}" >> ${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
|
echo "application-host=${toString cfg.listenAddress}" >> ${cfg.home}/nexus3/etc/nexus.properties
|
||||||
else
|
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-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
|
||||||
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
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
@ -346,6 +346,7 @@ in rec {
|
||||||
tests.networking.scripted = callSubTests tests/networking.nix { networkd = false; };
|
tests.networking.scripted = callSubTests tests/networking.nix { networkd = false; };
|
||||||
# TODO: put in networking.nix after the test becomes more complete
|
# TODO: put in networking.nix after the test becomes more complete
|
||||||
tests.networkingProxy = callTest tests/networking-proxy.nix {};
|
tests.networkingProxy = callTest tests/networking-proxy.nix {};
|
||||||
|
tests.nexus = callTest tests/nexus.nix { };
|
||||||
tests.nfs3 = callTest tests/nfs.nix { version = 3; };
|
tests.nfs3 = callTest tests/nfs.nix { version = 3; };
|
||||||
tests.nfs4 = callTest tests/nfs.nix { version = 4; };
|
tests.nfs4 = callTest tests/nfs.nix { version = 4; };
|
||||||
tests.nginx = callTest tests/nginx.nix { };
|
tests.nginx = callTest tests/nginx.nix { };
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# verifies:
|
# verifies:
|
||||||
# 1. nexus service starts on server
|
# 1. nexus service starts on server
|
||||||
# 2. nexus user can be extended on server
|
# 2. nexus service can startup on server (creating database and all other initial stuff)
|
||||||
# 3. nexus service not can startup on server (creating database and all other initial stuff)
|
# 3. the web application is reachable via HTTP
|
||||||
|
|
||||||
import ./make-test.nix ({ pkgs, ...} : {
|
import ./make-test.nix ({ pkgs, ...} : {
|
||||||
name = "nexus";
|
name = "nexus";
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
maintainers = [ ironpinguin ];
|
maintainers = [ ironpinguin ma27 ];
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
|
@ -14,21 +14,19 @@ import ./make-test.nix ({ pkgs, ...} : {
|
||||||
server =
|
server =
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
{ virtualisation.memorySize = 2048;
|
{ virtualisation.memorySize = 2048;
|
||||||
|
virtualisation.diskSize = 2048;
|
||||||
|
|
||||||
services.nexus.enable = true;
|
services.nexus.enable = true;
|
||||||
|
|
||||||
users.extraUsers.nexus.extraGroups = [ "users" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
startAll;
|
startAll;
|
||||||
|
|
||||||
$server->waitForUnit("nexus");
|
$server->waitForUnit("nexus");
|
||||||
|
|
||||||
print $server->execute("sudo -u nexus groups");
|
|
||||||
$server->mustSucceed("sudo -u nexus groups | grep nexus | grep users");
|
|
||||||
|
|
||||||
$server->waitForOpenPort(8081);
|
$server->waitForOpenPort(8081);
|
||||||
|
|
||||||
|
$server->succeed("curl -f 127.0.0.1:8081");
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
{ stdenv, fetchurl, makeWrapper, jre, gawk }:
|
{ stdenv, fetchurl, makeWrapper, jre, gawk }:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "nexus-${version}";
|
name = "nexus-${version}";
|
||||||
version = "3.5.1-02";
|
version = "3.11.0-01";
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-${version}-mac.tgz";
|
url = "https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-${version}-mac.tgz";
|
||||||
sha256 = "5ef3512c2bbdd45ef35921c1a0ba109b45bd9dad88311750196aa689262258b6";
|
sha256 = "1h5nfzb1sqhzb5j7w2dpmdi7vnnc9g6zx43a44f3zjvlxh1s0vim";
|
||||||
};
|
};
|
||||||
|
|
||||||
sourceRoot = name;
|
sourceRoot = name;
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
|
||||||
patches = [ ./nexus-bin.patch ];
|
patches = [ ./nexus-bin.patch ./nexus-vm-opts.patch ];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
substituteInPlace bin/nexus.vmoptions \
|
substituteInPlace bin/nexus.vmoptions \
|
||||||
--replace ../sonatype-work/nexus3 /run/sonatype-work/nexus3 \
|
|
||||||
--replace etc/karaf $out/etc/karaf \
|
--replace etc/karaf $out/etc/karaf \
|
||||||
--replace =. =$out
|
--replace =. =$out
|
||||||
'';
|
'';
|
||||||
|
@ -28,14 +28,12 @@ stdenv.mkDerivation rec {
|
||||||
cp -rfv * .install4j $out
|
cp -rfv * .install4j $out
|
||||||
rm -fv $out/bin/nexus.bat
|
rm -fv $out/bin/nexus.bat
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
wrapProgram $out/bin/nexus \
|
wrapProgram $out/bin/nexus \
|
||||||
--set JAVA_HOME ${jre} \
|
--set JAVA_HOME ${jre} \
|
||||||
--set ALTERNATIVE_NAME "nexus" \
|
--set ALTERNATIVE_NAME "nexus" \
|
||||||
--prefix PATH "${stdenv.lib.makeBinPath [ gawk ]}"
|
--prefix PATH "${stdenv.lib.makeBinPath [ gawk ]}"
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
|
@ -43,6 +41,6 @@ stdenv.mkDerivation rec {
|
||||||
homepage = http://www.sonatype.org/nexus;
|
homepage = http://www.sonatype.org/nexus;
|
||||||
license = licenses.epl10;
|
license = licenses.epl10;
|
||||||
platforms = platforms.all;
|
platforms = platforms.all;
|
||||||
maintainers = with maintainers; [ aespinosa ironpinguin ];
|
maintainers = with maintainers; [ aespinosa ironpinguin ma27 ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
diff --git a/bin/nexus b/bin/nexus
|
||||||
|
index e7ed3fb..8db766b 100755
|
||||||
|
--- a/bin/nexus
|
||||||
|
+++ b/bin/nexus
|
||||||
|
@@ -440,7 +440,8 @@ add_class_path "$app_home/lib/boot/org.apache.karaf.diagnostic.boot-4.0.9.jar"
|
||||||
|
add_class_path "$app_home/lib/boot/org.apache.karaf.jaas.boot-4.0.9.jar"
|
||||||
|
|
||||||
|
vmoptions_val=""
|
||||||
|
-read_vmoptions "$prg_dir/$progname.vmoptions"
|
||||||
|
+VM_OPTS=${VM_OPTS_FILE:-"$prg_dir/$progname.vmoptions"}
|
||||||
|
+read_vmoptions "$VM_OPTS"
|
||||||
|
INSTALL4J_ADD_VM_PARAMS="$INSTALL4J_ADD_VM_PARAMS $vmoptions_val"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue