diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index f8894df631ef..dba394a91d64 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -321,6 +321,7 @@ in { mimir = handleTest ./mimir.nix {}; garage = handleTest ./garage {}; gemstash = handleTest ./gemstash.nix {}; + geoserver = runTest ./geoserver.nix; gerrit = handleTest ./gerrit.nix {}; geth = handleTest ./geth.nix {}; ghostunnel = handleTest ./ghostunnel.nix {}; diff --git a/nixos/tests/geoserver.nix b/nixos/tests/geoserver.nix new file mode 100644 index 000000000000..7e5507a296ea --- /dev/null +++ b/nixos/tests/geoserver.nix @@ -0,0 +1,24 @@ +{ pkgs, lib, ... }: { + + name = "geoserver"; + meta = { + maintainers = with lib; [ teams.geospatial.members ]; + }; + + nodes = { + machine = { pkgs, ... }: { + virtualisation.diskSize = 2 * 1024; + + environment.systemPackages = [ pkgs.geoserver ]; + }; + }; + + testScript = '' + start_all() + + machine.execute("${pkgs.geoserver}/bin/geoserver-startup > /dev/null 2>&1 &") + machine.wait_until_succeeds("curl --fail --connect-timeout 2 http://localhost:8080/geoserver", timeout=60) + + machine.succeed("curl --fail --connect-timeout 2 http://localhost:8080/geoserver/ows?service=WMS&version=1.3.0&request=GetCapabilities") + ''; +} diff --git a/pkgs/servers/geospatial/geoserver/data-dir.patch b/pkgs/servers/geospatial/geoserver/data-dir.patch new file mode 100644 index 000000000000..869321627998 --- /dev/null +++ b/pkgs/servers/geospatial/geoserver/data-dir.patch @@ -0,0 +1,18 @@ +--- a/bin/startup.sh ++++ b/bin/startup.sh +@@ -66,12 +66,9 @@ fi + + #Find the configuration directory: GEOSERVER_DATA_DIR + if [ -z "${GEOSERVER_DATA_DIR:-}" ]; then +- if [ -r "${GEOSERVER_HOME}/data_dir" ]; then +- export GEOSERVER_DATA_DIR="${GEOSERVER_HOME}/data_dir" +- else +- echo "No GEOSERVER_DATA_DIR found, using application defaults" +- GEOSERVER_DATA_DIR="" +- fi ++ echo "GEOSERVER_DATA_DIR is not provided. Using $(pwd)/geoserver/data_dir directory" ++ mkdir -p "$(pwd)"/geoserver/data_dir ++ GEOSERVER_DATA_DIR="$(pwd)/geoserver/data_dir" + fi + + cd "${GEOSERVER_HOME}" || exit 1 diff --git a/pkgs/servers/geospatial/geoserver/default.nix b/pkgs/servers/geospatial/geoserver/default.nix index 4f0b657fda66..c0a8bfbdf77e 100644 --- a/pkgs/servers/geospatial/geoserver/default.nix +++ b/pkgs/servers/geospatial/geoserver/default.nix @@ -1,4 +1,12 @@ -{ lib, stdenv, fetchurl, unzip, jre, makeWrapper }: +{ lib +, fetchurl +, makeWrapper +, nixosTests +, stdenv + +, jre +, unzip +}: stdenv.mkDerivation rec { pname = "geoserver"; @@ -9,6 +17,11 @@ stdenv.mkDerivation rec { sha256 = "sha256-xX1rAONMh5XSWGPXkVMemAvG34DDNmu2018HsTvY7G0="; }; + patches = [ + # set GEOSERVER_DATA_DIR to current working directory if not provided + ./data-dir.patch + ]; + sourceRoot = "."; nativeBuildInputs = [ unzip makeWrapper ]; @@ -27,12 +40,16 @@ stdenv.mkDerivation rec { runHook postInstall ''; + passthru = { + tests.geoserver = nixosTests.geoserver; + }; + meta = with lib; { description = "Open source server for sharing geospatial data"; homepage = "https://geoserver.org/"; sourceProvenance = with sourceTypes; [ binaryBytecode ]; license = licenses.gpl2Plus; - maintainers = with maintainers; [ sikmir ]; + maintainers = teams.geospatial.members; platforms = platforms.all; }; }