···
dataDir = "/var/lib/matrix-appservice-discord";
registrationFile = "${dataDir}/discord-registration.yaml";
8
-
appDir = "${pkgs.matrix-appservice-discord}/${pkgs.matrix-appservice-discord.passthru.nodeAppDir}";
cfg = config.services.matrix-appservice-discord;
opt = options.services.matrix-appservice-discord;
# TODO: switch to configGen.json once RFC42 is implemented
···
services.matrix-appservice-discord = {
enable = mkEnableOption (lib.mdDoc "a bridge between Matrix and Discord");
18
+
package = mkOption {
19
+
type = types.package;
20
+
default = pkgs.matrix-appservice-discord;
21
+
defaultText = literalExpression "pkgs.matrix-appservice-discord";
22
+
description = lib.mdDoc ''
23
+
Which package of matrix-appservice-discord to use.
settings = mkOption rec {
# TODO: switch to types.config.json as prescribed by RFC42 once it's implemented
···
if [ ! -f '${registrationFile}' ]; then
117
-
${pkgs.matrix-appservice-discord}/bin/matrix-appservice-discord \
125
+
${cfg.package}/bin/matrix-appservice-discord \
--generate-registration \
--url=${escapeShellArg cfg.url} \
${optionalString (cfg.localpart != null) "--localpart=${escapeShellArg cfg.localpart}"} \
···
138
-
WorkingDirectory = appDir;
146
+
WorkingDirectory = "${cfg.package}/${cfg.package.passthru.nodeAppDir}";
StateDirectory = baseNameOf dataDir;
EnvironmentFile = cfg.environmentFile;
144
-
${pkgs.matrix-appservice-discord}/bin/matrix-appservice-discord \
152
+
${cfg.package}/bin/matrix-appservice-discord \
--file='${registrationFile}' \
--config='${settingsFile}' \
--port='${toString cfg.port}'