about summary refs log tree commit diff
path: root/nixos/modules/services/networking/thelounge.nix
diff options
context:
space:
mode:
authorMrmaxmeier <Mrmaxmeier@gmail.com>2019-07-22 18:52:20 +0200
committerMrmaxmeier <Mrmaxmeier@gmail.com>2019-07-23 13:18:01 +0200
commit37a2f058ed7ee008a8363933617ccb07db140541 (patch)
tree35508831743bfbe6416520f989330846019088f3 /nixos/modules/services/networking/thelounge.nix
parent09b004102ddbb83d83db36f3c350b8996862b9ec (diff)
downloadnixlib-37a2f058ed7ee008a8363933617ccb07db140541.tar
nixlib-37a2f058ed7ee008a8363933617ccb07db140541.tar.gz
nixlib-37a2f058ed7ee008a8363933617ccb07db140541.tar.bz2
nixlib-37a2f058ed7ee008a8363933617ccb07db140541.tar.lz
nixlib-37a2f058ed7ee008a8363933617ccb07db140541.tar.xz
nixlib-37a2f058ed7ee008a8363933617ccb07db140541.tar.zst
nixlib-37a2f058ed7ee008a8363933617ccb07db140541.zip
nixos/thelounge: init
The Lounge is the official and community-managed fork of Shout.
This intends to replace the `shout` service.
Diffstat (limited to 'nixos/modules/services/networking/thelounge.nix')
-rw-r--r--nixos/modules/services/networking/thelounge.nix75
1 files changed, 75 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/thelounge.nix b/nixos/modules/services/networking/thelounge.nix
new file mode 100644
index 000000000000..b1d23372955e
--- /dev/null
+++ b/nixos/modules/services/networking/thelounge.nix
@@ -0,0 +1,75 @@
+{ pkgs, lib, config, ... }:
+
+with lib;
+
+let
+  cfg = config.services.thelounge;
+  dataDir = "/var/lib/thelounge";
+  configJsData = "module.exports = " + builtins.toJSON (
+    { private = cfg.private; port = cfg.port; } // cfg.extraConfig
+  );
+in {
+  options.services.thelounge = {
+    enable = mkEnableOption "The Lounge web IRC client";
+
+    private = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        Make your The Lounge instance private. You will need to configure user
+        accounts by using the (<command>thelounge</command>) command or by adding
+        entries in <filename>${dataDir}/users</filename>. You might need to restart
+        The Lounge after making changes to the state directory.
+      '';
+    };
+
+    port = mkOption {
+      type = types.port;
+      default = 9000;
+      description = "TCP port to listen on for http connections.";
+    };
+
+    extraConfig = mkOption {
+      default = {};
+      type = types.attrs;
+      example = literalExample ''{
+        reverseProxy = true;
+        defaults = {
+          name = "Your Network";
+          host = "localhost";
+          port = 6697;
+        };
+      }'';
+      description = ''
+        The Lounge's <filename>config.js</filename> contents as attribute set (will be
+        converted to JSON to generate the configuration file).
+
+        The options defined here will be merged to the default configuration file.
+        Note: In case of duplicate configuration, options from <option>extraConfig</option> have priority.
+
+        Documentation: <link xlink:href="https://thelounge.chat/docs/server/configuration" />
+      '';
+    };
+  };
+
+  config = mkIf cfg.enable {
+    users.users.thelounge = {
+      description = "thelounge service user";
+      group = "thelounge";
+    };
+    users.groups.thelounge = {};
+    systemd.services.thelounge = {
+      description = "The Lounge web IRC client";
+      wantedBy = [ "multi-user.target" ];
+      environment = { THELOUNGE_HOME = dataDir; };
+      preStart = "ln -sf ${pkgs.writeText "config.js" configJsData} ${dataDir}/config.js";
+      serviceConfig = {
+        User = "thelounge";
+        StateDirectory = baseNameOf dataDir;
+        ExecStart = "${pkgs.thelounge}/bin/thelounge start";
+      };
+    };
+
+    environment.systemPackages = [ pkgs.thelounge ];
+  };
+}