summary refs log tree commit diff
path: root/nixos/modules/services/web-apps
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2018-06-26 01:16:51 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2018-06-26 01:18:30 +0200
commit2ef3ae559068c1ea495ec1fa007c9acd00575611 (patch)
tree018a9cf86a22f191ac73cfa1f3a33dd501836938 /nixos/modules/services/web-apps
parent1d235be2086dde14050fc811dc37528dec301783 (diff)
downloadnixlib-2ef3ae559068c1ea495ec1fa007c9acd00575611.tar
nixlib-2ef3ae559068c1ea495ec1fa007c9acd00575611.tar.gz
nixlib-2ef3ae559068c1ea495ec1fa007c9acd00575611.tar.bz2
nixlib-2ef3ae559068c1ea495ec1fa007c9acd00575611.tar.lz
nixlib-2ef3ae559068c1ea495ec1fa007c9acd00575611.tar.xz
nixlib-2ef3ae559068c1ea495ec1fa007c9acd00575611.tar.zst
nixlib-2ef3ae559068c1ea495ec1fa007c9acd00575611.zip
virtlyst service: init
Diffstat (limited to 'nixos/modules/services/web-apps')
-rw-r--r--nixos/modules/services/web-apps/virtlyst.nix72
1 files changed, 72 insertions, 0 deletions
diff --git a/nixos/modules/services/web-apps/virtlyst.nix b/nixos/modules/services/web-apps/virtlyst.nix
new file mode 100644
index 000000000000..2fc67435ce82
--- /dev/null
+++ b/nixos/modules/services/web-apps/virtlyst.nix
@@ -0,0 +1,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.extraUsers.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;
+      };
+    };
+  };
+
+}