{ lib, pkgs, config, ... }: with lib; { options = { gotify = { enable = mkEnableOption "enables gotify"; port = lib.mkOption { type = lib.types.int; default = 8857; description = "The port gotify listens on."; }; host = mkOption { type = types.str; defaultText = literalExpression "127.0.0.1"; description = "The hostname that gotify binds to"; }; domain = mkOption { type = types.str; defaultText = literalExpression "home.wastring.com"; description = "The hostname that gotify binds to"; }; }; }; config = mkMerge [ (mkIf config.gotify.enable { sops.secrets.gotify_password = { }; services.gotify = { enable = true; environmentFiles = [ config.sops.secrets.gotify_password.path ]; environment = { GOTIFY_DATABASE_DIALECT = "sqlite3"; GOTIFY_SERVER_PORT = config.gotify.port; GOTIFY_DEFAULTUSER_NAME = "admin"; }; }; services.nginx.virtualHosts.${config.gotify.domain} = { forceSSL = true; enableACME = true; locations."/" = { proxyPass = "http://${toString config.gotify.host}:${toString config.gotify.port}"; proxyWebsockets = true; }; }; }) ]; }