Update matrix
This commit is contained in:
parent
70e5a561f2
commit
a02661ede3
BIN
flake.lock
BIN
flake.lock
Binary file not shown.
|
@ -34,7 +34,7 @@
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
|
||||||
#./modules/packages/ooye/packages/module.nix
|
#./modules/packages/ooye/packages/module.nix
|
||||||
./host/matrix/matrix/ooye.nix
|
# ./host/matrix/matrix/ooye.nix
|
||||||
./host/matrix/unstable-overlay.nix
|
./host/matrix/unstable-overlay.nix
|
||||||
|
|
||||||
home-manager.nixosModules.home-manager
|
home-manager.nixosModules.home-manager
|
||||||
|
|
|
@ -11,8 +11,8 @@ buildNpmPackage rec {
|
||||||
version = "0";
|
version = "0";
|
||||||
src = fetchgit {
|
src = fetchgit {
|
||||||
url = "https://gitdab.com/cadence/out-of-your-element.git";
|
url = "https://gitdab.com/cadence/out-of-your-element.git";
|
||||||
rev = "07d6eb3c1272c2526a4749724c07c4fd530893d4";
|
rev = "bf01db13d66f4251dda4f20f3ef16a44f593d4ab";
|
||||||
sha256 = "3Y6s9pNKKeqF6s4I2Rd4TpxXPCwqizXeil/sTDVnpr0=";
|
sha256 = "/Q21Q4lhFXQOdGBhLBDfHnk/9WFSKjLiSzs96ugEcLU=";
|
||||||
};
|
};
|
||||||
npmDepsHash = "sha256-1STam+Sjy2MQcK5TmRacoxmgErd2sNqw0yIFX2M+iZk=";
|
npmDepsHash = "sha256-1STam+Sjy2MQcK5TmRacoxmgErd2sNqw0yIFX2M+iZk=";
|
||||||
dontNpmBuild = true;
|
dontNpmBuild = true;
|
||||||
|
|
|
@ -26,7 +26,9 @@ in
|
||||||
homeserverName = mkStringOption "The name of the homeserver to connect to." "localhost";
|
homeserverName = mkStringOption "The name of the homeserver to connect to." "localhost";
|
||||||
namespace = mkStringOption "The prefix to use for the MXIDs/aliases of bridged users/rooms. Should end with a _!" "_ooye_";
|
namespace = mkStringOption "The prefix to use for the MXIDs/aliases of bridged users/rooms. Should end with a _!" "_ooye_";
|
||||||
discordTokenPath = mkStringOption "The path to the discord token file." "/etc/ooye-discord-token";
|
discordTokenPath = mkStringOption "The path to the discord token file." "/etc/ooye-discord-token";
|
||||||
|
discordClientSecretPath = mkStringOption "The path to the discord token file." "/etc/ooye-discord-client-secret";
|
||||||
socket = mkStringOption "The socket to listen on, can either be a port number or a unix socket path." "6693";
|
socket = mkStringOption "The socket to listen on, can either be a port number or a unix socket path." "6693";
|
||||||
|
bridgeOrigin = mkStringOption "The web frontend URL for the bridge, defaults to http://localhost:{socket}" "";
|
||||||
|
|
||||||
enableSynapseIntegration = lib.mkEnableOption "Enable Synapse integration";
|
enableSynapseIntegration = lib.mkEnableOption "Enable Synapse integration";
|
||||||
};
|
};
|
||||||
|
@ -62,6 +64,7 @@ in
|
||||||
content_length_workaround = false;
|
content_length_workaround = false;
|
||||||
include_user_id_in_mxid = true;
|
include_user_id_in_mxid = true;
|
||||||
server_origin = cfg.homeserver;
|
server_origin = cfg.homeserver;
|
||||||
|
bridge_origin = if (cfg.bridgeOrigin == "") then "http://localhost:${cfg.socket}" else cfg.bridgeOrigin;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -85,24 +88,35 @@ script = pkgs.writeScript "matrix-ooye-pre-start.sh" ''
|
||||||
AS_TOKEN=$(${lib.getExe pkgs.jq} -r .as_token ''${REGISTRATION_FILE})
|
AS_TOKEN=$(${lib.getExe pkgs.jq} -r .as_token ''${REGISTRATION_FILE})
|
||||||
HS_TOKEN=$(${lib.getExe pkgs.jq} -r .hs_token ''${REGISTRATION_FILE})
|
HS_TOKEN=$(${lib.getExe pkgs.jq} -r .hs_token ''${REGISTRATION_FILE})
|
||||||
DISCORD_TOKEN=$(cat /run/credentials/matrix-ooye-pre-start.service/discord_token)
|
DISCORD_TOKEN=$(cat /run/credentials/matrix-ooye-pre-start.service/discord_token)
|
||||||
|
DISCORD_CLIENT_SECRET=$(cat /run/credentials/matrix-ooye-pre-start.service/discord_client_secret)
|
||||||
|
|
||||||
|
# Check if we have all required tokens
|
||||||
if [[ -z "$AS_TOKEN" || "$AS_TOKEN" == "null" ]]; then
|
if [[ -z "$AS_TOKEN" || "$AS_TOKEN" == "null" ]]; then
|
||||||
AS_TOKEN=$(${lib.getExe pkgs.openssl} rand -hex 64)
|
AS_TOKEN=$(${lib.getExe pkgs.openssl} rand -hex 64)
|
||||||
echo "Generated new AS token: ''${AS_TOKEN}"
|
echo "Generated new AS token: ''${AS_TOKEN}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$HS_TOKEN" || "$HS_TOKEN" == "null" ]]; then
|
if [[ -z "$HS_TOKEN" || "$HS_TOKEN" == "null" ]]; then
|
||||||
HS_TOKEN=$(${lib.getExe pkgs.openssl} rand -hex 64)
|
HS_TOKEN=$(${lib.getExe pkgs.openssl} rand -hex 64)
|
||||||
echo "Generated new HS token: ''${HS_TOKEN}"
|
echo "Generated new HS token: ''${HS_TOKEN}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$DISCORD_TOKEN" ]]; then
|
if [[ -z "$DISCORD_TOKEN" ]]; then
|
||||||
echo "No Discord token found at '${cfg.discordTokenPath}'"
|
echo "No Discord token found at '${cfg.discordTokenPath}'"
|
||||||
|
echo "You can find this on the 'Bot' tab of your Discord application."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$DISCORD_CLIENT_SECRET" ]]; then
|
||||||
|
echo "No Discord client secret found at '${cfg.discordTokenPath}'"
|
||||||
|
echo "You can find this on the 'OAuth2' tab of your Discord application."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shred -u ''${REGISTRATION_FILE}
|
shred -u ''${REGISTRATION_FILE}
|
||||||
cp --no-preserve=mode,ownership ${baseConfig} ''${REGISTRATION_FILE}
|
cp --no-preserve=mode,ownership ${baseConfig} ''${REGISTRATION_FILE}
|
||||||
|
|
||||||
${lib.getExe pkgs.jq} '.as_token = "'$AS_TOKEN'" | .hs_token = "'$HS_TOKEN'" | .ooye.discord_token = "'$DISCORD_TOKEN'"' ''${REGISTRATION_FILE} > ''${REGISTRATION_FILE}.tmp
|
${lib.getExe pkgs.jq} '.as_token = "'$AS_TOKEN'" | .hs_token = "'$HS_TOKEN'" | .ooye.discord_token = "'$DISCORD_TOKEN'" | .ooye.discord_client_secret = "'$DISCORD_CLIENT_SECRET'"' ''${REGISTRATION_FILE} > ''${REGISTRATION_FILE}.tmp
|
||||||
|
|
||||||
shred -u ''${REGISTRATION_FILE}
|
shred -u ''${REGISTRATION_FILE}
|
||||||
mv ''${REGISTRATION_FILE}.tmp ''${REGISTRATION_FILE}
|
mv ''${REGISTRATION_FILE}.tmp ''${REGISTRATION_FILE}
|
||||||
|
@ -118,6 +132,8 @@ script = pkgs.writeScript "matrix-ooye-pre-start.sh" ''
|
||||||
"OOYE namespace does not start with an underscore! This is recommended to avoid conflicts with registered users. Provided: '${cfg.namespace}'"
|
"OOYE namespace does not start with an underscore! This is recommended to avoid conflicts with registered users. Provided: '${cfg.namespace}'"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
environment.systemPackages = [ cfg.package ];
|
||||||
|
|
||||||
systemd.services."matrix-ooye-pre-start" = {
|
systemd.services."matrix-ooye-pre-start" = {
|
||||||
enable = true;
|
enable = true;
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
@ -126,9 +142,11 @@ script = pkgs.writeScript "matrix-ooye-pre-start.sh" ''
|
||||||
WorkingDirectory = "/var/lib/matrix-ooye";
|
WorkingDirectory = "/var/lib/matrix-ooye";
|
||||||
StateDirectory = "matrix-ooye";
|
StateDirectory = "matrix-ooye";
|
||||||
DynamicUser = true;
|
DynamicUser = true;
|
||||||
|
Type = "oneshot";
|
||||||
|
|
||||||
LoadCredential = [
|
LoadCredential = [
|
||||||
"discord_token:${cfg.discordTokenPath}"
|
"discord_token:${cfg.discordTokenPath}"
|
||||||
|
"discord_client_secret:${cfg.discordClientSecretPath}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -147,8 +165,8 @@ script = pkgs.writeScript "matrix-ooye-pre-start.sh" ''
|
||||||
"matrix-ooye-pre-start.service"
|
"matrix-ooye-pre-start.service"
|
||||||
"network-online.target"
|
"network-online.target"
|
||||||
];
|
];
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
requires = [ "matrix-ooye-pre-start.service" ];
|
requires = [ "matrix-ooye-pre-start.service" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = lib.getExe config.services.matrix-ooye.package;
|
ExecStart = lib.getExe config.services.matrix-ooye.package;
|
||||||
|
@ -164,11 +182,22 @@ script = pkgs.writeScript "matrix-ooye-pre-start.sh" ''
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services."matrix-synapse".serviceConfig = lib.mkIf cfg.enableSynapseIntegration {
|
systemd.services."matrix-synapse" = lib.mkIf cfg.enableSynapseIntegration {
|
||||||
|
|
||||||
|
after = [
|
||||||
|
"matrix-ooye-pre-start.service"
|
||||||
|
"network-online.target"
|
||||||
|
];
|
||||||
|
requires = [ "matrix-ooye-pre-start.service" ];
|
||||||
|
serviceConfig = {
|
||||||
LoadCredential = [
|
LoadCredential = [
|
||||||
"matrix-ooye-registration:/var/lib/matrix-ooye/registration.yaml"
|
"matrix-ooye-registration:/var/lib/matrix-ooye/registration.yaml"
|
||||||
];
|
];
|
||||||
ExecStartPre = "cp /run/credentials/matrix-synapse.service/registration.yaml ${config.services.matrix-synapse.dataDir}/ooye-registration.yaml";
|
ExecStartPre = [
|
||||||
|
"+${pkgs.coreutils}/bin/cp /run/credentials/matrix-synapse.service/matrix-ooye-registration ${config.services.matrix-synapse.dataDir}/ooye-registration.yaml"
|
||||||
|
"+${pkgs.coreutils}/bin/chown matrix-synapse:matrix-synapse ${config.services.matrix-synapse.dataDir}/ooye-registration.yaml"
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.matrix-synapse.settings.app_service_config_files = lib.mkIf cfg.enableSynapseIntegration [
|
services.matrix-synapse.settings.app_service_config_files = lib.mkIf cfg.enableSynapseIntegration [
|
||||||
|
|
22
test
Executable file
22
test
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/nix/store/p6k7xp1lsfmbdd731mlglrdj2d66mr82-bash-5.2p37/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo /nix/store/6a0f3b152k8h8rsnmp2zv8vi21z4812h-matrix-ooye-config.json
|
||||||
|
|
||||||
|
REGISTRATION_FILE=ooye-registration.json
|
||||||
|
AS_TOKEN=$(jq -r .as_token ${REGISTRATION_FILE})
|
||||||
|
HS_TOKEN=$(jq -r .hs_token ${REGISTRATION_FILE})
|
||||||
|
|
||||||
|
if [ -z "$AS_TOKEN" -o "$AS_TOKEN" == "null" ]; then
|
||||||
|
AS_TOKEN=$(openssl rand -hex 64)
|
||||||
|
echo "Generated new AS token: ${AS_TOKEN}"
|
||||||
|
fi
|
||||||
|
if [ -z "$HS_TOKEN" -o "$HS_TOKEN" == "null" ]; then
|
||||||
|
HS_TOKEN=$(openssl rand -hex 64)
|
||||||
|
echo "Generated new HS token: ${HS_TOKEN}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
/nix/store/iha35mp2hjhc77bkg6mf2zr2gyi6d05s-jq-1.7.1-bin/bin/jq '.as_token = "'$AS_TOKEN'" | .hs_token = "'$HS_TOKEN'"' ${REGISTRATION_FILE} > ${REGISTRATION_FILE}.tmp
|
||||||
|
|
||||||
|
|
||||||
|
|
0
test-build.sh
Normal file
0
test-build.sh
Normal file
Loading…
Reference in a new issue