dotfiles/nixng/containers/matrix/mautrix-discord/default.nix
magic_rb aff0158ef7
Reformat the whole flake using alejandra
Signed-off-by: magic_rb <magic_rb@redalder.org>
2024-03-02 22:17:03 +01:00

49 lines
1.4 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'
makeBinPath
;
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"
${getExe' pkgs.envsubst "envsubst"} < ${./mautrix-discord.yaml} > "$CONFIG_FILE"
chmod 755 "$CONFIG_FILE"
export PATH="$PATH:${makeBinPath [pkgs.lottieconverter]};"
[ -e "$REGISTRATION_FILE" ] || \
${getExe' mautrix-discord "mautrix-discord"} -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -g
${getExe' mautrix-discord "mautrix-discord"} -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -n
'';
};
};
};
}