nixos/thelounge: add plugins option
This commit is contained in:
parent
d53d2147ef
commit
fe20f479e9
|
@ -334,6 +334,15 @@
|
|||
<literal>true</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The option <literal>services.thelounge.plugins</literal> has
|
||||
been added to allow installing plugins for The Lounge. Plugins
|
||||
can be found in
|
||||
<literal>pkgs.theLoungePlugins.plugins</literal> and
|
||||
<literal>pkgs.theLoungePlugins.themes</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</section>
|
||||
|
|
|
@ -124,3 +124,5 @@ In addition to numerous new and upgraded packages, this release has the followin
|
|||
- `fetchFromSourcehut` now allows fetching repositories recursively
|
||||
using `fetchgit` or `fetchhg` if the argument `fetchSubmodules`
|
||||
is set to `true`.
|
||||
|
||||
- The option `services.thelounge.plugins` has been added to allow installing plugins for The Lounge. Plugins can be found in `pkgs.theLoungePlugins.plugins` and `pkgs.theLoungePlugins.themes`.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -440,6 +440,7 @@ let
|
|||
buildInputs = [ self.node-pre-gyp ];
|
||||
postInstall = ''
|
||||
echo /var/lib/thelounge > $out/lib/node_modules/thelounge/.thelounge_home
|
||||
patch -d $out/lib/node_modules/thelounge -p1 < ${./thelounge-packages-path.patch}
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
15
pkgs/development/node-packages/thelounge-packages-path.patch
Normal file
15
pkgs/development/node-packages/thelounge-packages-path.patch
Normal file
|
@ -0,0 +1,15 @@
|
|||
diff --git a/src/helper.js b/src/helper.js
|
||||
index 27352b53..7078e4c5 100644
|
||||
--- a/src/helper.js
|
||||
+++ b/src/helper.js
|
||||
@@ -110,6 +110,10 @@ function setHome(newPath) {
|
||||
userLogsPath = path.join(homePath, "logs");
|
||||
clientCertificatesPath = path.join(homePath, "certificates");
|
||||
|
||||
+ if (process.env.THELOUNGE_PACKAGES !== undefined) {
|
||||
+ packagesPath = process.env.THELOUNGE_PACKAGES;
|
||||
+ }
|
||||
+
|
||||
// Reload config from new home location
|
||||
if (fs.existsSync(configPath)) {
|
||||
const userConfig = require(configPath);
|
|
@ -10178,6 +10178,16 @@ with pkgs;
|
|||
|
||||
inherit (nodePackages) thelounge;
|
||||
|
||||
theLoungePlugins = with lib; let
|
||||
pkgs = filterAttrs (name: _: hasPrefix "thelounge-" name) nodePackages;
|
||||
getPackagesWithPrefix = prefix: mapAttrs' (name: pkg: nameValuePair (removePrefix ("thelounge-" + prefix + "-") name) pkg)
|
||||
(filterAttrs (name: _: hasPrefix ("thelounge-" + prefix + "-") name) pkgs);
|
||||
in
|
||||
{
|
||||
plugins = getPackagesWithPrefix "plugin";
|
||||
themes = getPackagesWithPrefix "theme";
|
||||
};
|
||||
|
||||
thefuck = python3Packages.callPackage ../tools/misc/thefuck { };
|
||||
|
||||
thicket = callPackage ../applications/version-management/git-and-tools/thicket { };
|
||||
|
|
Loading…
Reference in a new issue