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
|
|
|
|
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
|
|
|
|
2018-02-28 21:29:24 +01: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 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
|
|
|
};
|
2018-02-28 21:29:24 +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 {
|
2018-08-06 01:25:38 +02:00
|
|
|
dysnomia.enable = true;
|
2018-02-28 21:29:24 +01:00
|
|
|
|
2016-06-17 11:12:44 +02:00
|
|
|
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
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups = singleton
|
2010-04-19 15:26:21 +02:00
|
|
|
{ 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 = {
|
2018-02-28 21:29:24 +01:00
|
|
|
disnix = mkIf cfg.enableMultiUser {
|
2016-01-06 07:50:18 +01: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 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 {});
|
2018-02-28 21:29:24 +01:00
|
|
|
|
2016-06-17 11:12:44 +02:00
|
|
|
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
|
|
|
}
|