blob: 1b6eb94a56431636dbbc9b96d9c0ef8e49f23e2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# Disnix server
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.disnix;
in
{
###### interface
options = {
services.disnix = {
enable = lib.mkEnableOption "Disnix";
enableMultiUser = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to support multi-user mode by enabling the Disnix D-Bus service";
};
useWebServiceInterface = lib.mkEnableOption "the DisnixWebService interface running on Apache Tomcat";
package = lib.mkPackageOption pkgs "disnix" { };
enableProfilePath = lib.mkEnableOption "exposing the Disnix profiles in the system's PATH";
profiles = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "default" ];
description = "Names of the Disnix profiles to expose in the system's PATH";
};
};
};
###### implementation
config = lib.mkIf cfg.enable {
services.dysnomia.enable = true;
environment.systemPackages = [
pkgs.disnix
]
++ lib.optional cfg.useWebServiceInterface pkgs.disnix-web-service;
environment.variables.PATH = lib.optionals cfg.enableProfilePath (
map (profileName: "/nix/var/nix/profiles/disnix/${profileName}/bin") cfg.profiles
);
environment.variables.DISNIX_REMOTE_CLIENT = lib.optionalString (cfg.enableMultiUser) "disnix-client";
services.dbus.enable = true;
services.dbus.packages = [ pkgs.disnix ];
services.tomcat.enable = cfg.useWebServiceInterface;
services.tomcat.extraGroups = [ "disnix" ];
services.tomcat.javaOpts = "${lib.optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} ";
services.tomcat.sharedLibs =
lib.optional cfg.useWebServiceInterface "${pkgs.disnix-web-service}/share/java/DisnixConnection.jar"
++ lib.optional cfg.useWebServiceInterface "${pkgs.dbus_java}/share/java/dbus.jar";
services.tomcat.webapps = lib.optional cfg.useWebServiceInterface pkgs.disnix-web-service;
users.groups.disnix.gid = config.ids.gids.disnix;
systemd.services = {
disnix = lib.mkIf cfg.enableMultiUser {
description = "Disnix server";
wants = [ "dysnomia.target" ];
wantedBy = [ "multi-user.target" ];
after = [
"dbus.service"
]
++ lib.optional config.services.httpd.enable "httpd.service"
++ lib.optional config.services.mysql.enable "mysql.service"
++ lib.optional config.services.postgresql.enable "postgresql.target"
++ lib.optional config.services.tomcat.enable "tomcat.service"
++ lib.optional config.services.svnserve.enable "svnserve.service"
++ lib.optional config.services.mongodb.enable "mongodb.service"
++ lib.optional config.services.influxdb.enable "influxdb.service";
restartIfChanged = false;
path = [
config.nix.package
cfg.package
config.services.dysnomia.package
"/run/current-system/sw"
];
environment = {
HOME = "/root";
}
// (lib.optionalAttrs (config.environment.variables ? DYSNOMIA_CONTAINERS_PATH) {
inherit (config.environment.variables) DYSNOMIA_CONTAINERS_PATH;
})
// (lib.optionalAttrs (config.environment.variables ? DYSNOMIA_MODULES_PATH) {
inherit (config.environment.variables) DYSNOMIA_MODULES_PATH;
});
serviceConfig.ExecStart = "${cfg.package}/bin/disnix-service";
};
};
};
}
|