summary refs log tree commit diff
path: root/nixos/modules/services/networking/thelounge.nix
diff options
context:
space:
mode:
authorWinter <winter@winter.cafe>2022-01-08 22:05:05 -0500
committerWinter <winter@winter.cafe>2022-01-09 13:12:41 -0500
commitfe20f479e9a6bee55d47ad450ec81b07200a8168 (patch)
treea74a9a452aa18f82846da8eb6a29e78426f18d16 /nixos/modules/services/networking/thelounge.nix
parentd53d2147eff16f01b2345d4afed2de362979f551 (diff)
downloadnixpkgs-fe20f479e9a6bee55d47ad450ec81b07200a8168.tar
nixpkgs-fe20f479e9a6bee55d47ad450ec81b07200a8168.tar.gz
nixpkgs-fe20f479e9a6bee55d47ad450ec81b07200a8168.tar.bz2
nixpkgs-fe20f479e9a6bee55d47ad450ec81b07200a8168.tar.lz
nixpkgs-fe20f479e9a6bee55d47ad450ec81b07200a8168.tar.xz
nixpkgs-fe20f479e9a6bee55d47ad450ec81b07200a8168.tar.zst
nixpkgs-fe20f479e9a6bee55d47ad450ec81b07200a8168.zip
nixos/thelounge: add plugins option
Diffstat (limited to 'nixos/modules/services/networking/thelounge.nix')
-rw-r--r--nixos/modules/services/networking/thelounge.nix30
1 files changed, 26 insertions, 4 deletions
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: <link xlink:href="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
+        <literal>pkgs.theLoungePlugins.plugins</literal> and <literal>pkgs.theLoungePlugins.themes</literal>.
+      '';
+    };
   };
 
   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;