mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-12-04 22:14:58 +01:00
3f2887b439
Signed-off-by: magic_rb <magic_rb@redalder.org>
46 lines
1.4 KiB
Nix
46 lines
1.4 KiB
Nix
{inputs, ...}: {
|
|
flake.nixngConfigurations.mautrixFacebook = inputs.nixng.nglib.makeSystem {
|
|
system = "x86_64-linux";
|
|
name = "mautrix-facebook";
|
|
nixpkgs = inputs.nixpkgs-stable;
|
|
config = {
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}: let
|
|
inherit
|
|
(lib)
|
|
singleton
|
|
;
|
|
in {
|
|
dumb-init = {
|
|
enable = true;
|
|
type.services = {};
|
|
};
|
|
|
|
init.services.mautrix-facebook = {
|
|
enabled = true;
|
|
shutdownOnExit = true;
|
|
script = let
|
|
mautrix-facebook = pkgs.mautrix-facebook.overridePythonAttrs (old: {
|
|
propagatedBuildInputs = singleton pkgs.python3.pkgs.aiosqlite ++ old.propagatedBuildInputs;
|
|
});
|
|
in
|
|
pkgs.writeShellScript "mautrix-facebook"
|
|
''
|
|
DATA_DIR="/var/lib/mautrix-facebook"
|
|
CONFIG_FILE="$DATA_DIR/config.yaml"
|
|
REGISTRATION_FILE="/var/lib/registrations/mautrix-facebook.yaml"
|
|
DB_FILE="$DATA_DIR/sqlite.db"
|
|
|
|
cp ${./mautrix-facebook.yaml} "$CONFIG_FILE" ; chmod 755 "$CONFIG_FILE"
|
|
${pkgs.sqlite}/bin/sqlite3 $DB_FILE '.databases ; .quit'
|
|
|
|
[ -e "$REGISTRATION_FILE" ] || \
|
|
${mautrix-facebook}/bin/mautrix-facebook -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -g
|
|
${mautrix-facebook}/bin/mautrix-facebook -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -n
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|