mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-29 03:26:13 +01:00
c1a727a699
Signed-off-by: Magic_RB <magic_rb@redalder.org>
42 lines
1.3 KiB
Nix
42 lines
1.3 KiB
Nix
{ inputs, config, ... }:
|
|
{
|
|
flake.nixngConfigurations.mautrixDiscord = inputs.nixng.nglib.makeSystem {
|
|
system = "x86_64-linux";
|
|
name = "mautrix-discord";
|
|
inherit (inputs) nixpkgs;
|
|
config =
|
|
{ pkgs, lib, ... }:
|
|
{
|
|
dumb-init = {
|
|
enable = true;
|
|
type.services = { };
|
|
};
|
|
|
|
init.services.mautrix-discord = {
|
|
enabled = true;
|
|
shutdownOnExit = true;
|
|
script =
|
|
let
|
|
inherit (lib)
|
|
getExe;
|
|
mautrix-discord = (pkgs.appendOverlays [ config.flake.overlays.mautrix-discord ]).mautrix-discord;
|
|
in
|
|
pkgs.writeShellScript "mautrix-discord"
|
|
''
|
|
DATA_DIR="/var/lib/mautrix-discord"
|
|
CONFIG_FILE="$DATA_DIR/config.yaml"
|
|
REGISTRATION_FILE="/var/lib/registrations/mautrix-discord.yaml"
|
|
DB_FILE="$DATA_DIR/sqlite.db"
|
|
|
|
${getExe pkgs.envsubst} < ${./mautrix-discord.yaml} > "$CONFIG_FILE"
|
|
chmod 755 "$CONFIG_FILE"
|
|
|
|
[ -e "$REGISTRATION_FILE" ] || \
|
|
${getExe mautrix-discord} -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -g
|
|
${getExe mautrix-discord} -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -n
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|