1 { pkgs, lib, config, ... }:
6 cfg = config.services.thelounge;
7 dataDir = "/var/lib/thelounge";
8 configJsData = "module.exports = " + builtins.toJSON (
9 { inherit (cfg) public port; } // cfg.extraConfig
12 dependencies = builtins.listToAttrs (builtins.map (pkg: { name = getName pkg; value = getVersion pkg; }) cfg.plugins);
14 plugins = pkgs.runCommandLocal "thelounge-plugins" { } ''
15 mkdir -p $out/node_modules
16 echo ${escapeShellArg (builtins.toJSON pluginManifest)} >> $out/package.json
17 ${concatMapStringsSep "\n" (pkg: ''
18 ln -s ${pkg}/lib/node_modules/${getName pkg} $out/node_modules/${getName pkg}
23 imports = [ (mkRemovedOptionModule [ "services" "thelounge" "private" ] "The option was renamed to `services.thelounge.public` to follow upstream changes.") ];
25 options.services.thelounge = {
26 enable = mkEnableOption (lib.mdDoc "The Lounge web IRC client");
31 description = lib.mdDoc ''
32 Make your The Lounge instance public.
33 Setting this to `false` will require you to configure user
34 accounts by using the ({command}`thelounge`) command or by adding
35 entries in {file}`${dataDir}/users`. You might need to restart
36 The Lounge after making changes to the state directory.
43 description = lib.mdDoc "TCP port to listen on for http connections.";
46 extraConfig = mkOption {
49 example = literalExpression ''{
52 name = "Your Network";
57 description = lib.mdDoc ''
58 The Lounge's {file}`config.js` contents as attribute set (will be
59 converted to JSON to generate the configuration file).
61 The options defined here will be merged to the default configuration file.
62 Note: In case of duplicate configuration, options from {option}`extraConfig` have priority.
64 Documentation: <https://thelounge.chat/docs/server/configuration>
70 type = types.listOf types.package;
71 example = literalExpression "[ pkgs.theLoungePlugins.themes.solarized ]";
72 description = lib.mdDoc ''
73 The Lounge plugins to install. Plugins can be found in
74 `pkgs.theLoungePlugins.plugins` and `pkgs.theLoungePlugins.themes`.
79 config = mkIf cfg.enable {
80 users.users.thelounge = {
81 description = "The Lounge service user";
86 users.groups.thelounge = { };
88 systemd.services.thelounge = {
89 description = "The Lounge web IRC client";
90 wantedBy = [ "multi-user.target" ];
91 preStart = "ln -sf ${pkgs.writeText "config.js" configJsData} ${dataDir}/config.js";
92 environment.THELOUNGE_PACKAGES = mkIf (cfg.plugins != [ ]) "${plugins}";
95 StateDirectory = baseNameOf dataDir;
96 ExecStart = "${pkgs.thelounge}/bin/thelounge start";
100 environment.systemPackages = [ pkgs.thelounge ];
104 maintainers = with lib.maintainers; [ winter ];