Merge pull request #153038 from winterqt/thelounge-plugins

This commit is contained in:
Martin Weinelt 2022-01-10 00:59:33 +01:00 committed by GitHub
commit 24999924b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 7569 additions and 4535 deletions

View file

@ -343,6 +343,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>

View file

@ -126,3 +126,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`.

View file

@ -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;
@ -72,4 +94,8 @@ in {
environment.systemPackages = [ pkgs.thelounge ];
};
meta = {
maintainers = with lib.maintainers; [ winter ];
};
}

View file

@ -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}
'';
};

View file

@ -289,6 +289,45 @@
, "textlint-rule-unexpanded-acronym"
, "textlint-rule-write-good"
, "thelounge"
, "thelounge-plugin-closepms"
, "thelounge-plugin-giphy"
, "thelounge-plugin-shortcuts"
, "thelounge-theme-abyss"
, "thelounge-theme-amoled"
, "thelounge-theme-amoled-sourcecodepro"
, "thelounge-theme-bdefault"
, "thelounge-theme-bmorning"
, "thelounge-theme-chord"
, "thelounge-theme-classic"
, "thelounge-theme-common"
, "thelounge-theme-crypto"
, "thelounge-theme-discordapp"
, "thelounge-theme-dracula"
, "thelounge-theme-dracula-official"
, "thelounge-theme-flat-blue"
, "thelounge-theme-flat-dark"
, "thelounge-theme-gruvbox"
, "thelounge-theme-hexified"
, "thelounge-theme-ion"
, "thelounge-theme-light"
, "thelounge-theme-midnight"
, "thelounge-theme-mininapse"
, "thelounge-theme-monokai-console"
, "thelounge-theme-mortified"
, "thelounge-theme-neuron-fork"
, "thelounge-theme-new-morning"
, "thelounge-theme-new-morning-compact"
, "thelounge-theme-nologo"
, "thelounge-theme-nord"
, "thelounge-theme-onedark"
, "thelounge-theme-purplenight"
, "thelounge-theme-scoutlink"
, "thelounge-theme-seraphimrp"
, "thelounge-theme-solarized"
, "thelounge-theme-solarized-fork-monospace"
, "thelounge-theme-zenburn"
, "thelounge-theme-zenburn-monospace"
, "thelounge-theme-zenburn-sourcecodepro"
, "three"
, "tiddlywiki"
, "titanium"

File diff suppressed because it is too large Load diff

View 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);

View file

@ -10120,6 +10120,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 { };