diff options
author | Rickard Nilsson <rickynils@gmail.com> | 2014-03-12 22:06:28 +0100 |
---|---|---|
committer | Rickard Nilsson <rickynils@gmail.com> | 2014-03-12 23:14:09 +0100 |
commit | f24940330b21bc42dc3cd1379632782feb358f11 (patch) | |
tree | dc967a0cd860af45e523534d6fb3373dc9f674fe /nixos | |
parent | ec3dbdf93dfd639aab058b07e33dc62172893b95 (diff) | |
download | nixlib-f24940330b21bc42dc3cd1379632782feb358f11.tar nixlib-f24940330b21bc42dc3cd1379632782feb358f11.tar.gz nixlib-f24940330b21bc42dc3cd1379632782feb358f11.tar.bz2 nixlib-f24940330b21bc42dc3cd1379632782feb358f11.tar.lz nixlib-f24940330b21bc42dc3cd1379632782feb358f11.tar.xz nixlib-f24940330b21bc42dc3cd1379632782feb358f11.tar.zst nixlib-f24940330b21bc42dc3cd1379632782feb358f11.zip |
New NixOS module: services.winstone, for running instances of the Winstone Java Servlet container
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/web-servers/winstone.nix | 120 |
2 files changed, 121 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index d67d7d040dcb..0a3654b3824d 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -231,6 +231,7 @@ ./services/web-servers/phpfpm.nix ./services/web-servers/tomcat.nix ./services/web-servers/varnish/default.nix + ./services/web-servers/winstone.nix ./services/web-servers/zope2.nix ./services/x11/desktop-managers/default.nix ./services/x11/display-managers/auto.nix diff --git a/nixos/modules/services/web-servers/winstone.nix b/nixos/modules/services/web-servers/winstone.nix new file mode 100644 index 000000000000..8904745ed17c --- /dev/null +++ b/nixos/modules/services/web-servers/winstone.nix @@ -0,0 +1,120 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +let + + cfg = config.services.winstone; + + winstoneOpts = { name, ... }: { + options = { + name = mkOption { + default = name; + internal = true; + }; + + warFile = mkOption { + type = types.str; + description = '' + The WAR file that Winstone should serve. + ''; + }; + + javaPackage = mkOption { + type = types.package; + default = pkgs.openjre; + description = '' + Which Java derivation to use for running Winstone. + ''; + }; + + user = mkOption { + type = types.str; + description = '' + The user that should run this Winstone process and + own the working directory. + ''; + }; + + group = mkOption { + type = types.str; + description = '' + The group that will own the working directory. + ''; + }; + + workDir = mkOption { + type = types.str; + description = '' + The working directory for this Winstone instance. Will + contain extracted webapps etc. The directory will be + created if it doesn't exist. + ''; + }; + + extraJavaOptions = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra command line options given to the java process running + Winstone. + ''; + }; + + extraOptions = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra command line options given to the Winstone process. + ''; + }; + }; + + config = { + workDir = mkDefault "/run/winstone/${name}"; + }; + }; + + mkService = cfg: let + opts = concatStringsSep " " (cfg.extraOptions ++ [ + "--warfile ${cfg.warFile}" + ]); + + javaOpts = concatStringsSep " " (cfg.extraJavaOptions ++ [ + "-Djava.io.tmpdir=${cfg.workDir}" + "-jar ${pkgs.winstone}/lib/winstone.jar" + ]); + in { + wantedBy = [ "multi-user.target" ]; + description = "winstone service for ${cfg.name}"; + preStart = '' + mkdir -p "${cfg.workDir}" + chown ${cfg.user}:${cfg.group} "${cfg.workDir}" + ''; + serviceConfig = { + ExecStart = "${cfg.javaPackage}/bin/java ${javaOpts} ${opts}"; + User = cfg.user; + PermissionsStartOnly = true; + }; + }; + +in { + + options = { + services.winstone = mkOption { + default = {}; + type = types.attrsOf types.optionSet; + options = [ winstoneOpts ]; + description = '' + Defines independent Winstone services, each serving one WAR-file. + ''; + }; + }; + + config = mkIf (cfg != {}) { + + systemd.services = mapAttrs' (n: c: nameValuePair "winstone-${n}" (mkService c)) cfg; + + }; + +} |