mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-28 12:06:38 +03:00

Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase
).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
130 lines
3.5 KiB
Nix
130 lines
3.5 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.thelounge;
|
|
dataDir = "/var/lib/thelounge";
|
|
configJsData =
|
|
"module.exports = " + builtins.toJSON ({ inherit (cfg) public port; } // cfg.extraConfig);
|
|
pluginManifest = {
|
|
dependencies = builtins.listToAttrs (
|
|
builtins.map (pkg: {
|
|
name = getName pkg;
|
|
value = getVersion pkg;
|
|
}) cfg.plugins
|
|
);
|
|
};
|
|
plugins =
|
|
pkgs.runCommand "thelounge-plugins"
|
|
{
|
|
preferLocalBuild = true;
|
|
}
|
|
''
|
|
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.")
|
|
];
|
|
|
|
options.services.thelounge = {
|
|
enable = mkEnableOption "The Lounge web IRC client";
|
|
|
|
package = mkPackageOption pkgs "thelounge" { };
|
|
|
|
public = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Make your The Lounge instance public.
|
|
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
|
|
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 = literalExpression ''
|
|
{
|
|
reverseProxy = true;
|
|
defaults = {
|
|
name = "Your Network";
|
|
host = "localhost";
|
|
port = 6697;
|
|
};
|
|
}
|
|
'';
|
|
description = ''
|
|
The Lounge's {file}`config.js` 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` have priority.
|
|
|
|
Documentation: <https://thelounge.chat/docs/server/configuration>
|
|
'';
|
|
};
|
|
|
|
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
|
|
`pkgs.theLoungePlugins.plugins` and `pkgs.theLoungePlugins.themes`.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
users.users.thelounge = {
|
|
description = "The Lounge 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";
|
|
environment.THELOUNGE_PACKAGES = mkIf (cfg.plugins != [ ]) "${plugins}";
|
|
serviceConfig = {
|
|
User = "thelounge";
|
|
StateDirectory = baseNameOf dataDir;
|
|
ExecStart = "${getExe cfg.package} start";
|
|
};
|
|
};
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
};
|
|
|
|
meta = {
|
|
maintainers = with lib.maintainers; [ winter ];
|
|
};
|
|
}
|