2022-09-19 13:51:54 +02:00
|
|
|
{ nglib, nixpkgs }:
|
|
|
|
nglib.makeSystem {
|
|
|
|
system = "x86_64-linux";
|
2022-09-22 15:17:34 +02:00
|
|
|
name = "mautrix-facebook";
|
2022-09-19 13:51:54 +02:00
|
|
|
inherit nixpkgs;
|
|
|
|
config = ({ pkgs, ... }:
|
|
|
|
{
|
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
|
|
|
type.services = { };
|
|
|
|
};
|
|
|
|
|
|
|
|
init.services.mautrix-facebook = {
|
|
|
|
enabled = true;
|
|
|
|
shutdownOnExit = true;
|
|
|
|
script =
|
|
|
|
let
|
2022-09-19 15:05:43 +02:00
|
|
|
config = ./mautrix-facebook.yaml;
|
2022-09-19 13:51:54 +02:00
|
|
|
in
|
|
|
|
pkgs.writeShellScript "mautrix-facebook"
|
|
|
|
''
|
2022-09-19 15:31:15 +02:00
|
|
|
DATA_DIR="/var/lib/mautrix-facebook"
|
|
|
|
CONFIG_FILE="$DATA_DIR/config.yaml"
|
2022-09-19 23:19:37 +02:00
|
|
|
REGISTRATION_FILE="/var/lib/registrations/mautrix-facebook.yaml"
|
2022-09-19 15:31:15 +02:00
|
|
|
DB_FILE="$DATA_DIR/sqlite.db"
|
2022-09-19 15:49:43 +02:00
|
|
|
|
2022-09-19 15:22:58 +02:00
|
|
|
cp ${config} "$CONFIG_FILE" ; chmod 755 "$CONFIG_FILE"
|
2022-09-19 15:31:15 +02:00
|
|
|
${pkgs.sqlite}/bin/sqlite3 $DB_FILE '.databases ; .quit'
|
2022-09-19 15:49:43 +02:00
|
|
|
|
2022-09-19 23:41:10 +02:00
|
|
|
[ -e "$REGISTRATION_FILE" ] || \
|
|
|
|
${pkgs.mautrix-facebook}/bin/mautrix-facebook -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -g
|
2022-09-19 15:49:43 +02:00
|
|
|
${pkgs.mautrix-facebook}/bin/mautrix-facebook -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -n
|
2022-09-19 13:51:54 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|