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.runCommand "thelounge-plugins" {
15 preferLocalBuild = true;
17 mkdir -p $out/node_modules
18 echo ${escapeShellArg (builtins.toJSON pluginManifest)} >> $out/package.json
19 ${concatMapStringsSep "\n" (pkg: ''
20 ln -s ${pkg}/lib/node_modules/${getName pkg} $out/node_modules/${getName pkg}
25 imports = [ (mkRemovedOptionModule [ "services" "thelounge" "private" ] "The option was renamed to `services.thelounge.public` to follow upstream changes.") ];
27 options.services.thelounge = {
28 enable = mkEnableOption "The Lounge web IRC client";
30 package = mkPackageOption pkgs "thelounge" { };
36 Make your The Lounge instance public.
37 Setting this to `false` will require you to configure user
38 accounts by using the ({command}`thelounge`) command or by adding
39 entries in {file}`${dataDir}/users`. You might need to restart
40 The Lounge after making changes to the state directory.
47 description = "TCP port to listen on for http connections.";
50 extraConfig = mkOption {
53 example = literalExpression ''
57 name = "Your Network";
64 The Lounge's {file}`config.js` contents as attribute set (will be
65 converted to JSON to generate the configuration file).
67 The options defined here will be merged to the default configuration file.
68 Note: In case of duplicate configuration, options from {option}`extraConfig` have priority.
70 Documentation: <https://thelounge.chat/docs/server/configuration>
76 type = types.listOf types.package;
77 example = literalExpression "[ pkgs.theLoungePlugins.themes.solarized ]";
79 The Lounge plugins to install. Plugins can be found in
80 `pkgs.theLoungePlugins.plugins` and `pkgs.theLoungePlugins.themes`.
85 config = mkIf cfg.enable {
86 users.users.thelounge = {
87 description = "The Lounge service user";
92 users.groups.thelounge = { };
94 systemd.services.thelounge = {
95 description = "The Lounge web IRC client";
96 wantedBy = [ "multi-user.target" ];
97 preStart = "ln -sf ${pkgs.writeText "config.js" configJsData} ${dataDir}/config.js";
98 environment.THELOUNGE_PACKAGES = mkIf (cfg.plugins != [ ]) "${plugins}";
101 StateDirectory = baseNameOf dataDir;
102 ExecStart = "${getExe cfg.package} start";
106 environment.systemPackages = [ cfg.package ];
110 maintainers = with lib.maintainers; [ winter ];