diff options
author | Lara <lara@uwu.is> | 2021-12-22 15:23:49 +0000 |
---|---|---|
committer | Lara <lara@uwu.is> | 2022-01-23 11:27:39 +0000 |
commit | 2a701e80619658fd6554f2c2370545b511da087e (patch) | |
tree | 042da6de5a34c0d6b73e3519d52743676aafae85 | |
parent | 3c2143ee7f1591b641c06eb8ac476c1b8c12e791 (diff) | |
download | nixpkgs-2a701e80619658fd6554f2c2370545b511da087e.tar nixpkgs-2a701e80619658fd6554f2c2370545b511da087e.tar.gz nixpkgs-2a701e80619658fd6554f2c2370545b511da087e.tar.bz2 nixpkgs-2a701e80619658fd6554f2c2370545b511da087e.tar.lz nixpkgs-2a701e80619658fd6554f2c2370545b511da087e.tar.xz nixpkgs-2a701e80619658fd6554f2c2370545b511da087e.tar.zst nixpkgs-2a701e80619658fd6554f2c2370545b511da087e.zip |
nixos/matrix-synapse: Wrap register_new_matrix_user
`register_new_matrix_user` is a script provided by the matrix-synapse package to create a new matrix user on the command line. This commit provides a wrapper around `register_new_matrix_user` that automatically passes the url (and `registration_shared_secret`, if present) as CLI arguments.
-rw-r--r-- | nixos/modules/services/misc/matrix-synapse.nix | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/matrix-synapse.nix b/nixos/modules/services/misc/matrix-synapse.nix index 404163d2de6..de13a153c6f 100644 --- a/nixos/modules/services/misc/matrix-synapse.nix +++ b/nixos/modules/services/misc/matrix-synapse.nix @@ -119,6 +119,30 @@ ${cfg.extraConfig} hasLocalPostgresDB = let args = cfg.database_args; in usePostgresql && (!(args ? host) || (elem args.host [ "localhost" "127.0.0.1" "::1" ])); + + registerNewMatrixUser = + let + isIpv6 = x: lib.length (lib.splitString ":" x) > 1; + listener = + lib.findFirst ( + listener: lib.any ( + resource: lib.any ( + name: name == "client" + ) resource.names + ) listener.resources + ) (lib.last cfg.listeners) cfg.listeners; + in + pkgs.writeShellScriptBin "matrix-synapse-register_new_matrix_user" '' + exec ${cfg.package}/bin/register_new_matrix_user \ + $@ \ + ${lib.concatMapStringsSep " " (x: "-c ${x}") ([ configFile ] ++ cfg.extraConfigFiles)} \ + "${listener.type}://${ + if (isIpv6 listener.bind_address) then + "[${listener.bind_address}]" + else + "${listener.bind_address}" + }:${builtins.toString listener.port}/" + ''; in { options = { services.matrix-synapse = { @@ -792,6 +816,8 @@ in { UMask = "0077"; }; }; + + environment.systemPackages = [ registerNewMatrixUser ]; }; imports = [ |