mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-29 09:04:17 +00:00
df2f8d9150
The output file is found and handled by thelounge itself [1], leaving
the user free to override THELOUNGE_HOME in the environment if they
choose, but having a sensible default to make `thelounge` generally
usable in most cases.
This solution follows discussion on #70318.
[1] 9ef5c6c67e/src/command-line/utils.js (L56)
76 lines
2.3 KiB
Nix
76 lines
2.3 KiB
Nix
{ 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";
|
|
isSystemUser = true;
|
|
};
|
|
users.groups.thelounge = {};
|
|
systemd.services.thelounge = {
|
|
description = "The Lounge web IRC client";
|
|
wantedBy = [ "multi-user.target" ];
|
|
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 ];
|
|
};
|
|
}
|