2008-11-18 19:00:15 +01:00
|
|
|
# Disnix server
|
2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-10-12 18:36:19 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2008-07-06 20:34:19 +02:00
|
|
|
|
|
|
|
let
|
2009-10-12 18:36:19 +02:00
|
|
|
|
|
|
|
cfg = config.services.disnix;
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2013-06-27 15:32:49 +02:00
|
|
|
dysnomia = pkgs.dysnomia.override (origArgs: {
|
2010-11-01 18:33:54 +01:00
|
|
|
enableApacheWebApplication = config.services.httpd.enable;
|
|
|
|
enableAxis2WebService = config.services.tomcat.axis2.enable;
|
|
|
|
enableEjabberdDump = config.services.ejabberd.enable;
|
|
|
|
enableMySQLDatabase = config.services.mysql.enable;
|
2010-12-22 14:32:51 +01:00
|
|
|
enablePostgreSQLDatabase = config.services.postgresql.enable;
|
|
|
|
enableSubversionRepository = config.services.svnserve.enable;
|
2010-11-01 18:33:54 +01:00
|
|
|
enableTomcatWebApplication = config.services.tomcat.enable;
|
2013-11-07 10:54:53 +01:00
|
|
|
enableMongoDatabase = config.services.mongodb.enable;
|
2010-11-01 18:33:54 +01:00
|
|
|
});
|
2009-10-12 18:36:19 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2008-11-18 19:00:15 +01:00
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
services.disnix = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable Disnix";
|
2010-11-01 18:33:54 +01:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-11-01 18:33:54 +01:00
|
|
|
useWebServiceInterface = mkOption {
|
|
|
|
default = false;
|
2012-02-06 23:49:41 +01:00
|
|
|
description = "Whether to enable the DisnixWebService interface running on Apache Tomcat";
|
2010-11-01 18:33:54 +01:00
|
|
|
};
|
2016-06-17 11:12:44 +02:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
description = "The Disnix package";
|
|
|
|
default = pkgs.disnix;
|
2016-11-21 16:26:03 +01:00
|
|
|
defaultText = "pkgs.disnix";
|
2010-11-21 14:28:48 +01:00
|
|
|
};
|
2009-10-12 18:36:19 +02:00
|
|
|
|
2008-11-18 19:00:15 +01:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2008-11-18 19:00:15 +01:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
###### implementation
|
2008-11-18 19:00:15 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
config = mkIf cfg.enable {
|
2016-06-17 11:12:44 +02:00
|
|
|
dysnomia.enable = true;
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.disnix ] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService;
|
2008-11-18 19:00:15 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
services.dbus.enable = true;
|
|
|
|
services.dbus.packages = [ pkgs.disnix ];
|
2008-11-18 19:00:15 +01:00
|
|
|
|
2010-11-01 18:33:54 +01:00
|
|
|
services.tomcat.enable = cfg.useWebServiceInterface;
|
2010-11-01 20:01:26 +01:00
|
|
|
services.tomcat.extraGroups = [ "disnix" ];
|
2010-11-01 18:33:54 +01:00
|
|
|
services.tomcat.javaOpts = "${optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} ";
|
2010-12-10 15:22:00 +01:00
|
|
|
services.tomcat.sharedLibs = optional cfg.useWebServiceInterface "${pkgs.DisnixWebService}/share/java/DisnixConnection.jar"
|
2016-06-17 11:12:44 +02:00
|
|
|
++ optional cfg.useWebServiceInterface "${pkgs.dbus_java}/share/java/dbus.jar";
|
2010-12-10 15:22:00 +01:00
|
|
|
services.tomcat.webapps = optional cfg.useWebServiceInterface pkgs.DisnixWebService;
|
2010-11-01 18:33:54 +01:00
|
|
|
|
2010-04-19 15:26:21 +02:00
|
|
|
users.extraGroups = singleton
|
|
|
|
{ name = "disnix";
|
|
|
|
gid = config.ids.gids.disnix;
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2016-01-06 07:50:18 +01:00
|
|
|
systemd.services = {
|
|
|
|
disnix = {
|
|
|
|
description = "Disnix server";
|
|
|
|
wants = [ "dysnomia.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "dbus.service" ]
|
|
|
|
++ optional config.services.httpd.enable "httpd.service"
|
|
|
|
++ optional config.services.mysql.enable "mysql.service"
|
|
|
|
++ optional config.services.postgresql.enable "postgresql.service"
|
|
|
|
++ optional config.services.tomcat.enable "tomcat.service"
|
|
|
|
++ optional config.services.svnserve.enable "svnserve.service"
|
|
|
|
++ optional config.services.mongodb.enable "mongodb.service";
|
|
|
|
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
2016-06-17 11:12:44 +02:00
|
|
|
path = [ config.nix.package cfg.package config.dysnomia.package "/run/current-system/sw" ];
|
2016-01-06 07:50:18 +01:00
|
|
|
|
|
|
|
environment = {
|
|
|
|
HOME = "/root";
|
2016-06-17 11:12:44 +02:00
|
|
|
}
|
|
|
|
// (if config.environment.variables ? DYSNOMIA_CONTAINERS_PATH then { inherit (config.environment.variables) DYSNOMIA_CONTAINERS_PATH; } else {})
|
|
|
|
// (if config.environment.variables ? DYSNOMIA_MODULES_PATH then { inherit (config.environment.variables) DYSNOMIA_MODULES_PATH; } else {});
|
|
|
|
|
|
|
|
serviceConfig.ExecStart = "${cfg.package}/bin/disnix-service";
|
2016-01-06 07:50:18 +01:00
|
|
|
};
|
|
|
|
|
2010-12-10 15:22:00 +01:00
|
|
|
};
|
2008-11-18 19:00:15 +01:00
|
|
|
};
|
2008-07-06 20:34:19 +02:00
|
|
|
}
|