2020-04-24 23:36:52 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.thelounge;
|
|
|
|
dataDir = "/var/lib/thelounge";
|
|
|
|
configJsData = "module.exports = " + builtins.toJSON (
|
2022-01-13 20:06:32 +00:00
|
|
|
{ inherit (cfg) public port; } // cfg.extraConfig
|
2020-04-24 23:36:52 +00:00
|
|
|
);
|
2022-01-13 20:06:32 +00:00
|
|
|
pluginManifest = {
|
|
|
|
dependencies = builtins.listToAttrs (builtins.map (pkg: { name = getName pkg; value = getVersion pkg; }) cfg.plugins);
|
|
|
|
};
|
|
|
|
plugins = pkgs.runCommandLocal "thelounge-plugins" { } ''
|
|
|
|
mkdir -p $out/node_modules
|
|
|
|
echo ${escapeShellArg (builtins.toJSON pluginManifest)} >> $out/package.json
|
|
|
|
${concatMapStringsSep "\n" (pkg: ''
|
|
|
|
ln -s ${pkg}/lib/node_modules/${getName pkg} $out/node_modules/${getName pkg}
|
|
|
|
'') cfg.plugins}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [ (mkRemovedOptionModule [ "services" "thelounge" "private" ] "The option was renamed to `services.thelounge.public` to follow upstream changes.") ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
options.services.thelounge = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "The Lounge web IRC client");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
package = mkPackageOptionMD pkgs "thelounge" { };
|
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
public = mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-01-13 20:06:32 +00:00
|
|
|
Make your The Lounge instance public.
|
2022-08-12 12:06:08 +00:00
|
|
|
Setting this to `false` will require you to configure user
|
|
|
|
accounts by using the ({command}`thelounge`) command or by adding
|
|
|
|
entries in {file}`${dataDir}/users`. You might need to restart
|
2020-04-24 23:36:52 +00:00
|
|
|
The Lounge after making changes to the state directory.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 9000;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "TCP port to listen on for http connections.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
2022-01-13 20:06:32 +00:00
|
|
|
default = { };
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.attrs;
|
2023-07-15 17:15:38 +00:00
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
reverseProxy = true;
|
|
|
|
defaults = {
|
|
|
|
name = "Your Network";
|
|
|
|
host = "localhost";
|
|
|
|
port = 6697;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
The Lounge's {file}`config.js` contents as attribute set (will be
|
2020-04-24 23:36:52 +00:00
|
|
|
converted to JSON to generate the configuration file).
|
|
|
|
|
|
|
|
The options defined here will be merged to the default configuration file.
|
2022-08-12 12:06:08 +00:00
|
|
|
Note: In case of duplicate configuration, options from {option}`extraConfig` have priority.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
Documentation: <https://thelounge.chat/docs/server/configuration>
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
2022-01-13 20:06:32 +00:00
|
|
|
|
|
|
|
plugins = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.package;
|
|
|
|
example = literalExpression "[ pkgs.theLoungePlugins.themes.solarized ]";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-01-13 20:06:32 +00:00
|
|
|
The Lounge plugins to install. Plugins can be found in
|
2022-08-12 12:06:08 +00:00
|
|
|
`pkgs.theLoungePlugins.plugins` and `pkgs.theLoungePlugins.themes`.
|
2022-01-13 20:06:32 +00:00
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.users.thelounge = {
|
2022-01-13 20:06:32 +00:00
|
|
|
description = "The Lounge service user";
|
2020-04-24 23:36:52 +00:00
|
|
|
group = "thelounge";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
2022-01-13 20:06:32 +00:00
|
|
|
|
|
|
|
users.groups.thelounge = { };
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.services.thelounge = {
|
|
|
|
description = "The Lounge web IRC client";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
preStart = "ln -sf ${pkgs.writeText "config.js" configJsData} ${dataDir}/config.js";
|
2022-01-13 20:06:32 +00:00
|
|
|
environment.THELOUNGE_PACKAGES = mkIf (cfg.plugins != [ ]) "${plugins}";
|
2020-04-24 23:36:52 +00:00
|
|
|
serviceConfig = {
|
|
|
|
User = "thelounge";
|
|
|
|
StateDirectory = baseNameOf dataDir;
|
2023-07-15 17:15:38 +00:00
|
|
|
ExecStart = "${getExe cfg.package} start";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-01-13 20:06:32 +00:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
maintainers = with lib.maintainers; [ winter ];
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|