You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.5 KiB
Nix

{pkgs}: {applicationName, application}:
with pkgs.stdenv.lib;
let
serviceName = "node-${applicationName}-error-reporter";
cfg = config.services."${serviceName}";
# FIXME: report-errors NPM package!
in {
options.services."${serviceName}" = {
enable = mkEnableOption "${name} Error Reporter";
stackFilter = mkOption {
description = ''
What modules to filter out of the simplified stacktraces
shown in the e-mail report. This can either be the
string "*" (to filter out every third-party module), or
an array of module names to filter.
Note that the e-mail will always include a JSON
attachment containing the full stacktrace - this setting
purely affects the e-mail body.
'';
default = "*";
type = types.either types.str (types.listOf types.str);
};
subjectFormat = mkOption {
description = ''
The format for the subject line of the report e-mail. In
this string, `$type` will be replaced with the error
type/name, and `$message` will be replaced with the
error message.
'';
default = "UNHANDLED ERROR: $type - $message";
type = types.str;
};
metadata = {
from = mkOption {
description = ''
The sender address displayed on the e-mail report.
'';
type = types.str;
};
to = mkOption {
description = ''
The address to e-mail reports to.
'';
type = types.str;
};
};
smtp = {
hostname = mkOption {
description = ''
The hostname on which the SMTP server can be
reached.
'';
default = null;
type = types.nullOr types.str;
};
port = mkOption {
description = ''
The port number that the SMTP server is accessible
on.
'';
default = null;
type = types.nullOr types.str;
};
username = mkOption {
description = ''
Your username for the SMTP server.
'';
default = null;
type = types.nullOr types.str;
};
password = mkOption {
description = ''
Your password for the SMTP server.
'';
default = null;
type = types.nullOr types.str;
};
};
};
config = {
services."${serviceName}" = mkIf cfg.enabled {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${pkgs.nodejs_6_x}/bin/node ${application}/node_modules/report-errors/lib/daemon/index.js";
User = systemd.services."node-${applicationName}".serviceConfig.User; # MARKER
};
};
};
}