about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2023-11-12 19:57:01 +0900
committersefidel <contact@sefidel.net>2023-11-12 19:57:01 +0900
commit4e9dc134d4323856f29cdcda4979ce3682753d72 (patch)
tree44646b8f5573740ec9c00f5a8c50d8a5f53bcd99
parent2c27931d491a39f190f788d19dd455124d347885 (diff)
downloadinfra-4e9dc134d4323856f29cdcda4979ce3682753d72.tar.gz
infra-4e9dc134d4323856f29cdcda4979ce3682753d72.zip
feat(overlays/matrix-signal-module): support setting package
-rw-r--r--overlays/mautrix-signal-module.nix14
1 files changed, 8 insertions, 6 deletions
diff --git a/overlays/mautrix-signal-module.nix b/overlays/mautrix-signal-module.nix
index 22abbb5..27c1a36 100644
--- a/overlays/mautrix-signal-module.nix
+++ b/overlays/mautrix-signal-module.nix
@@ -16,6 +16,8 @@ in
     services.mautrix-signal = {
       enable = mkEnableOption (lib.mdDoc "Mautrix-Signal, a Matrix-Signal puppeting bridge.");
 
+      package = mkOption { type = types.package; default = pkgs.mautrix-signal; };
+
       settings = mkOption rec {
         apply = recursiveUpdate default;
         inherit (settingsFormat) type;
@@ -155,15 +157,15 @@ in
       preStart = ''
         # generate the appservice's registration file if absent
         if [ ! -f '${registrationFile}' ]; then
-          ${pkgs.mautrix-signal}/bin/mautrix-signal \
+          ${cfg.package}/bin/mautrix-signal \
             --generate-registration \
-            --base-config='${pkgs.mautrix-signal}/${pkgs.mautrix-signal.pythonModule.sitePackages}/mautrix_signal/example-config.yaml' \
+            --base-config='${cfg.package}/${cfg.package.pythonModule.sitePackages}/mautrix_signal/example-config.yaml' \
             --config='${settingsFile}' \
             --registration='${registrationFile}'
         fi
-      '' + lib.optionalString (pkgs.mautrix-signal ? alembic) ''
+      '' + lib.optionalString (cfg.package ? alembic) ''
         # run automatic database init and migration scripts
-        ${pkgs.mautrix-signal.alembic}/bin/alembic -x config='${settingsFile}' upgrade head
+        ${cfg.package.alembic}/bin/alembic -x config='${settingsFile}' upgrade head
       '';
 
       serviceConfig = {
@@ -179,13 +181,13 @@ in
         DynamicUser = true;
         SupplementaryGroups = [ "signald" ];
         PrivateTmp = true;
-        WorkingDirectory = pkgs.mautrix-signal; # necessary for the database migration scripts to be found
+        WorkingDirectory = cfg.package; # necessary for the database migration scripts to be found
         StateDirectory = baseNameOf dataDir;
         UMask = "0027";
         EnvironmentFile = cfg.environmentFile;
 
         ExecStart = ''
-          ${pkgs.mautrix-signal}/bin/mautrix-signal \
+          ${cfg.package}/bin/mautrix-signal \
             --config='${settingsFile}'
         '';
       };