2019-07-22 17:52:20 +01:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.thelounge;
|
|
|
|
dataDir = "/var/lib/thelounge";
|
|
|
|
configJsData = "module.exports = " + builtins.toJSON (
|
2021-07-07 17:45:21 +01:00
|
|
|
{ inherit (cfg) public port; } // cfg.extraConfig
|
2019-07-22 17:52:20 +01:00
|
|
|
);
|
2022-01-09 03:05:05 +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
|
|
|
|
{
|
2021-07-07 17:45:21 +01:00
|
|
|
imports = [ (mkRemovedOptionModule [ "services" "thelounge" "private" ] "The option was renamed to `services.thelounge.public` to follow upstream changes.") ];
|
|
|
|
|
2019-07-22 17:52:20 +01:00
|
|
|
options.services.thelounge = {
|
|
|
|
enable = mkEnableOption "The Lounge web IRC client";
|
|
|
|
|
2021-07-07 17:45:21 +01:00
|
|
|
public = mkOption {
|
2019-07-22 17:52:20 +01:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2021-07-07 17:45:21 +01:00
|
|
|
Make your The Lounge instance public.
|
|
|
|
Setting this to <literal>false</literal> will require you to configure user
|
2019-07-22 17:52:20 +01:00
|
|
|
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 {
|
2022-01-09 03:05:05 +00:00
|
|
|
default = { };
|
2019-07-22 17:52:20 +01:00
|
|
|
type = types.attrs;
|
2021-10-03 17:06:03 +01:00
|
|
|
example = literalExpression ''{
|
2019-07-22 17:52:20 +01:00
|
|
|
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" />
|
|
|
|
'';
|
|
|
|
};
|
2022-01-09 03:05:05 +00:00
|
|
|
|
|
|
|
plugins = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.package;
|
|
|
|
example = literalExpression "[ pkgs.theLoungePlugins.themes.solarized ]";
|
|
|
|
description = ''
|
|
|
|
The Lounge plugins to install. Plugins can be found in
|
|
|
|
<literal>pkgs.theLoungePlugins.plugins</literal> and <literal>pkgs.theLoungePlugins.themes</literal>.
|
|
|
|
'';
|
|
|
|
};
|
2019-07-22 17:52:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.users.thelounge = {
|
2022-01-09 03:05:05 +00:00
|
|
|
description = "The Lounge service user";
|
2019-07-22 17:52:20 +01:00
|
|
|
group = "thelounge";
|
2019-10-12 21:25:28 +01:00
|
|
|
isSystemUser = true;
|
2019-07-22 17:52:20 +01:00
|
|
|
};
|
2021-07-07 17:45:21 +01:00
|
|
|
|
2022-01-09 03:05:05 +00:00
|
|
|
users.groups.thelounge = { };
|
2021-07-07 17:45:21 +01:00
|
|
|
|
2019-07-22 17:52:20 +01: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-09 03:05:05 +00:00
|
|
|
environment.THELOUNGE_PACKAGES = mkIf (cfg.plugins != [ ]) "${plugins}";
|
2019-07-22 17:52:20 +01:00
|
|
|
serviceConfig = {
|
|
|
|
User = "thelounge";
|
|
|
|
StateDirectory = baseNameOf dataDir;
|
|
|
|
ExecStart = "${pkgs.thelounge}/bin/thelounge start";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.thelounge ];
|
|
|
|
};
|
2022-01-09 03:47:43 +00:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
maintainers = with lib.maintainers; [ winter ];
|
|
|
|
};
|
2019-07-22 17:52:20 +01:00
|
|
|
}
|