From fe20f479e9a6bee55d47ad450ec81b07200a8168 Mon Sep 17 00:00:00 2001 From: Winter Date: Sat, 8 Jan 2022 22:05:05 -0500 Subject: nixos/thelounge: add plugins option --- nixos/modules/services/networking/thelounge.nix | 30 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'nixos/modules/services/networking/thelounge.nix') diff --git a/nixos/modules/services/networking/thelounge.nix b/nixos/modules/services/networking/thelounge.nix index b9449163916..f330c61db24 100644 --- a/nixos/modules/services/networking/thelounge.nix +++ b/nixos/modules/services/networking/thelounge.nix @@ -8,7 +8,18 @@ let configJsData = "module.exports = " + builtins.toJSON ( { private = cfg.private; port = cfg.port; } // cfg.extraConfig ); -in { + 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 +{ options.services.thelounge = { enable = mkEnableOption "The Lounge web IRC client"; @@ -30,7 +41,7 @@ in { }; extraConfig = mkOption { - default = {}; + default = { }; type = types.attrs; example = literalExpression ''{ reverseProxy = true; @@ -50,19 +61,30 @@ in { Documentation: ''; }; + + 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 = "thelounge service user"; + description = "The Lounge service user"; group = "thelounge"; isSystemUser = true; }; - users.groups.thelounge = {}; + 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; -- cgit 1.4.1