@@ -7,7 +7,6 @@ let
77
88 conf = pkgs.writeText "collectd.conf" ''
99 BaseDir "${cfg.dataDir}"
10− PIDFile "${cfg.pidFile}"
1110 AutoLoadPlugin ${boolToString cfg.autoLoadPlugin}
1211 Hostname "${config.networking.hostName}"
1312
@@ -26,13 +25,7 @@ let
2625
2726in {
2827 options.services.collectd = with types; {
29− enable = mkOption {
30− default = false;
31− description = ''
32− Whether to enable collectd agent.
33− '';
34− type = bool;
35− };
28+ enable = mkEnableOption "collectd agent";
3629
3730 package = mkOption {
3831 default = pkgs.collectd;
@@ -59,14 +52,6 @@ in {
5952 type = path;
6053 };
6154
62− pidFile = mkOption {
63− default = "/var/run/collectd.pid";
64− description = ''
65− Location of collectd pid file.
66− '';
67− type = path;
68− };
69−
7055 autoLoadPlugin = mkOption {
7156 default = false;
7257 description = ''
@@ -100,27 +85,20 @@ in {
10085 wantedBy = [ "multi-user.target" ];
10186
10287 serviceConfig = {
103− ExecStart = "${cfg.package}/sbin/collectd -C ${conf} -P ${cfg.pidFile}";
104− Type = "forking";
105− PIDFile = cfg.pidFile;
106− User = optional (cfg.user!="root") cfg.user;
88+ ExecStart = "${cfg.package}/sbin/collectd -C ${conf} -f";
89+ User = cfg.user;
10790 PermissionsStartOnly = true;
10891 };
10992
11093 preStart = ''
111− mkdir -p ${cfg.dataDir}
112− chmod 755 ${cfg.dataDir}
113− install -D /dev/null ${cfg.pidFile}
114− if [ "$(id -u)" = 0 ]; then
115− chown -R ${cfg.user} ${cfg.dataDir};
116− chown ${cfg.user} ${cfg.pidFile}
117− fi
94+ mkdir -p "${cfg.dataDir}"
95+ chmod 755 "${cfg.dataDir}"
96+ chown -R ${cfg.user} "${cfg.dataDir}"
11897 '';
119− };
98+ };
12099
121100 users.extraUsers = optional (cfg.user == "collectd") {
122101 name = "collectd";
123− uid = config.ids.uids.collectd;
124102 };
125103 };
126104}