blob: e5c0bff2168ae31e657228269e7a856011b36e39 (
plain) (
blame)
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
|
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.virtlyst;
stateDir = "/var/lib/virtlyst";
ini = pkgs.writeText "virtlyst-config.ini" ''
[wsgi]
master = true
threads = auto
http-socket = ${cfg.httpSocket}
application = ${pkgs.virtlyst}/lib/libVirtlyst.so
chdir2 = ${stateDir}
static-map = /static=${pkgs.virtlyst}/root/static
[Cutelyst]
production = true
DatabasePath = virtlyst.sqlite
TemplatePath = ${pkgs.virtlyst}/root/src
[Rules]
cutelyst.* = true
virtlyst.* = true
'';
in
{
options.services.virtlyst = {
enable = mkEnableOption "Virtlyst libvirt web interface";
adminPassword = mkOption {
type = types.str;
description = ''
Initial admin password with which the database will be seeded.
'';
};
httpSocket = mkOption {
type = types.str;
default = "localhost:3000";
description = ''
IP and/or port to which to bind the http socket.
'';
};
};
config = mkIf cfg.enable {
users.users.virtlyst = {
home = stateDir;
createHome = true;
group = mkIf config.virtualisation.libvirtd.enable "libvirtd";
};
systemd.services.virtlyst = {
wantedBy = [ "multi-user.target" ];
environment = {
VIRTLYST_ADMIN_PASSWORD = cfg.adminPassword;
};
serviceConfig = {
ExecStart = "${pkgs.cutelyst}/bin/cutelyst-wsgi2 --ini ${ini}";
User = "virtlyst";
WorkingDirectory = stateDir;
};
};
};
}
|