2008-11-18 18:00:15 +00:00
|
|
|
# Disnix server
|
2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-10-12 17:36:19 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2008-07-06 19:34:19 +01:00
|
|
|
|
|
|
|
let
|
2009-10-12 17:36:19 +01:00
|
|
|
|
|
|
|
cfg = config.services.disnix;
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2013-06-27 14:32:49 +01:00
|
|
|
dysnomia = pkgs.dysnomia.override (origArgs: {
|
2010-11-01 17:33:54 +00: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 13:32:51 +00:00
|
|
|
enablePostgreSQLDatabase = config.services.postgresql.enable;
|
|
|
|
enableSubversionRepository = config.services.svnserve.enable;
|
2010-11-01 17:33:54 +00:00
|
|
|
enableTomcatWebApplication = config.services.tomcat.enable;
|
2013-11-07 09:54:53 +00:00
|
|
|
enableMongoDatabase = config.services.mongodb.enable;
|
2010-11-01 17:33:54 +00:00
|
|
|
});
|
2009-10-12 17:36:19 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2008-11-18 18:00:15 +00:00
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
services.disnix = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable Disnix";
|
2010-11-01 17:33:54 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2018-02-28 20:29:24 +00:00
|
|
|
enableMultiUser = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Whether to support multi-user mode by enabling the Disnix D-Bus service";
|
|
|
|
};
|
|
|
|
|
2010-11-01 17:33:54 +00:00
|
|
|
useWebServiceInterface = mkOption {
|
|
|
|
default = false;
|
2012-02-06 22:49:41 +00:00
|
|
|
description = "Whether to enable the DisnixWebService interface running on Apache Tomcat";
|
2010-11-01 17:33:54 +00:00
|
|
|
};
|
2018-02-28 20:29:24 +00:00
|
|
|
|
2016-06-17 10:12:44 +01:00
|
|
|
package = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
description = "The Disnix package";
|
|
|
|
default = pkgs.disnix;
|
2016-11-21 15:26:03 +00:00
|
|
|
defaultText = "pkgs.disnix";
|
2010-11-21 13:28:48 +00:00
|
|
|
};
|
2009-10-12 17:36:19 +01:00
|
|
|
|
2008-11-18 18:00:15 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2008-11-18 18:00:15 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
###### implementation
|
2008-11-18 18:00:15 +00:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
config = mkIf cfg.enable {
|
2018-03-26 19:51:07 +01:00
|
|
|
services.dysnomia.enable = true;
|
2018-02-28 20:29:24 +00:00
|
|
|
|
2016-06-17 10:12:44 +01:00
|
|
|
environment.systemPackages = [ pkgs.disnix ] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService;
|
2008-11-18 18:00:15 +00:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
services.dbus.enable = true;
|
|
|
|
services.dbus.packages = [ pkgs.disnix ];
|
2008-11-18 18:00:15 +00:00
|
|
|
|
2010-11-01 17:33:54 +00:00
|
|
|
services.tomcat.enable = cfg.useWebServiceInterface;
|
2010-11-01 19:01:26 +00:00
|
|
|
services.tomcat.extraGroups = [ "disnix" ];
|
2010-11-01 17:33:54 +00:00
|
|
|
services.tomcat.javaOpts = "${optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} ";
|
2010-12-10 14:22:00 +00:00
|
|
|
services.tomcat.sharedLibs = optional cfg.useWebServiceInterface "${pkgs.DisnixWebService}/share/java/DisnixConnection.jar"
|
2016-06-17 10:12:44 +01:00
|
|
|
++ optional cfg.useWebServiceInterface "${pkgs.dbus_java}/share/java/dbus.jar";
|
2010-12-10 14:22:00 +00:00
|
|
|
services.tomcat.webapps = optional cfg.useWebServiceInterface pkgs.DisnixWebService;
|
2010-11-01 17:33:54 +00:00
|
|
|
|
2010-04-19 14:26:21 +01:00
|
|
|
users.extraGroups = singleton
|
|
|
|
{ name = "disnix";
|
|
|
|
gid = config.ids.gids.disnix;
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2016-01-06 06:50:18 +00:00
|
|
|
systemd.services = {
|
2018-02-28 20:29:24 +00:00
|
|
|
disnix = mkIf cfg.enableMultiUser {
|
2016-01-06 06:50:18 +00:00
|
|
|
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 10:12:44 +01:00
|
|
|
path = [ config.nix.package cfg.package config.dysnomia.package "/run/current-system/sw" ];
|
2016-01-06 06:50:18 +00:00
|
|
|
|
|
|
|
environment = {
|
|
|
|
HOME = "/root";
|
2016-06-17 10:12:44 +01: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 {});
|
2018-02-28 20:29:24 +00:00
|
|
|
|
2016-06-17 10:12:44 +01:00
|
|
|
serviceConfig.ExecStart = "${cfg.package}/bin/disnix-service";
|
2016-01-06 06:50:18 +00:00
|
|
|
};
|
|
|
|
|
2010-12-10 14:22:00 +00:00
|
|
|
};
|
2008-11-18 18:00:15 +00:00
|
|
|
};
|
2008-07-06 19:34:19 +01:00
|
|
|
}
|