mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
nixos/smartd: add systembus-notify notifications
This commit is contained in:
parent
2faf6e0bf9
commit
20a73ab51d
1 changed files with 27 additions and 0 deletions
|
@ -10,6 +10,7 @@ let
|
||||||
opt = options.services.smartd;
|
opt = options.services.smartd;
|
||||||
|
|
||||||
nm = cfg.notifications.mail;
|
nm = cfg.notifications.mail;
|
||||||
|
ns = cfg.notifications.systembus-notify;
|
||||||
nw = cfg.notifications.wall;
|
nw = cfg.notifications.wall;
|
||||||
nx = cfg.notifications.x11;
|
nx = cfg.notifications.x11;
|
||||||
|
|
||||||
|
@ -28,6 +29,12 @@ let
|
||||||
${pkgs.smartmontools}/sbin/smartctl -a -d "$SMARTD_DEVICETYPE" "$SMARTD_DEVICE"
|
${pkgs.smartmontools}/sbin/smartctl -a -d "$SMARTD_DEVICETYPE" "$SMARTD_DEVICE"
|
||||||
} | ${nm.mailer} -i "${nm.recipient}"
|
} | ${nm.mailer} -i "${nm.recipient}"
|
||||||
''}
|
''}
|
||||||
|
${optionalString ns.enable ''
|
||||||
|
${pkgs.dbus}/bin/dbus-send --system \
|
||||||
|
/ net.nuetzlich.SystemNotifications.Notify \
|
||||||
|
"string:Problem detected with disk: $SMARTD_DEVICESTRING" \
|
||||||
|
"string:Warning message from smartd is: $SMARTD_MESSAGE"
|
||||||
|
''}
|
||||||
${optionalString nw.enable ''
|
${optionalString nw.enable ''
|
||||||
{
|
{
|
||||||
${pkgs.coreutils}/bin/cat << EOF
|
${pkgs.coreutils}/bin/cat << EOF
|
||||||
|
@ -159,6 +166,24 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systembus-notify = {
|
||||||
|
enable = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Whenever to send systembus-notify notifications.
|
||||||
|
|
||||||
|
WARNING: enabling this option (while convenient) should *not* be done on a
|
||||||
|
machine where you do not trust the other users as it allows any other
|
||||||
|
local user to DoS your session by spamming notifications.
|
||||||
|
|
||||||
|
To actually see the notifications in your GUI session, you need to have
|
||||||
|
`systembus-notify` running as your user, which this
|
||||||
|
option handles by enabling {option}`services.systembus-notify`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
wall = {
|
wall = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -247,6 +272,8 @@ in
|
||||||
serviceConfig.ExecStart = "${pkgs.smartmontools}/sbin/smartd ${lib.concatStringsSep " " cfg.extraOptions} --no-fork --configfile=${smartdConf}";
|
serviceConfig.ExecStart = "${pkgs.smartmontools}/sbin/smartd ${lib.concatStringsSep " " cfg.extraOptions} --no-fork --configfile=${smartdConf}";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.systembus-notify.enable = mkDefault ns.enable;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue