mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-12-13 10:22:02 +01:00
67df3e94fb
Signed-off-by: magic_rb <magic_rb@redalder.org>
38 lines
1.3 KiB
Nix
38 lines
1.3 KiB
Nix
{inputs, ...}: {
|
|
flake.nixngConfigurations.mautrixSignal = inputs.nixng.nglib.makeSystem {
|
|
system = "x86_64-linux";
|
|
name = "mautrix-signal";
|
|
inherit (inputs) nixpkgs;
|
|
config = {
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}: {
|
|
dumb-init = {
|
|
enable = true;
|
|
type.services = {};
|
|
};
|
|
|
|
init.services.mautrix-signal = {
|
|
enabled = true;
|
|
shutdownOnExit = true;
|
|
script = pkgs.writeShellScript "mautrix-signal" ''
|
|
DATA_DIR="/var/lib/mautrix-signal"
|
|
CONFIG_FILE="$DATA_DIR/config.yaml"
|
|
REGISTRATION_FILE="/var/lib/registrations/mautrix-signal.yaml"
|
|
DB_FILE="$DATA_DIR/sqlite.db"
|
|
|
|
cp ${./mautrix-signal.yaml} "$CONFIG_FILE" ; chmod 755 "$CONFIG_FILE"
|
|
|
|
[ -e "$REGISTRATION_FILE" ] || \
|
|
${lib.getExe' pkgs.mautrix-signal "mautrix-signal"} -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -g
|
|
sed -i \
|
|
-e 's/@AS_TOKEN@/'"$(${lib.getExe pkgs.yq} -r '.as_token' "$REGISTRATION_FILE")/" \
|
|
-e 's/@HS_TOKEN@/'"$(${lib.getExe pkgs.yq} -r '.hs_token' "$REGISTRATION_FILE")/" \
|
|
"$CONFIG_FILE"
|
|
${lib.getExe' pkgs.mautrix-signal "mautrix-signal"} -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -n
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|