mbpfan: service improvements

* add verbosity setting
* don't set mbpfan as a setuid program
This commit is contained in:
Charles Strahan 2015-05-01 17:11:00 -04:00
parent 4c01e6d919
commit ba50d48400

View File

@ -4,6 +4,7 @@ with lib;
let let
cfg = config.services.mbpfan; cfg = config.services.mbpfan;
verbose = if cfg.verbose then "v" else "";
in { in {
options.services.mbpfan = { options.services.mbpfan = {
@ -69,13 +70,19 @@ in {
The polling interval. The polling interval.
''; '';
}; };
verbose = mkOption {
type = types.bool;
default = false;
description = ''
If true, sets the log level to verbose.
'';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
boot.kernelModules = [ "coretemp" "applesmc" ]; boot.kernelModules = [ "coretemp" "applesmc" ];
security.setuidPrograms = [ "mbpfan" ];
environment = { environment = {
etc."mbpfan.conf".text = '' etc."mbpfan.conf".text = ''
[general] [general]
@ -96,7 +103,7 @@ in {
restartTriggers = [ config.environment.etc."mbpfan.conf".source ]; restartTriggers = [ config.environment.etc."mbpfan.conf".source ];
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
ExecStart = "${cfg.package}/bin/mbpfan -fv"; ExecStart = "${cfg.package}/bin/mbpfan -f${verbose}";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
PIDFile = "/var/run/mbpfan.pid"; PIDFile = "/var/run/mbpfan.pid";
Restart = "always"; Restart = "always";