1 { config, lib, pkgs, ... }:
7 cfg = config.services.fcron;
9 queuelen = optionalString (cfg.queuelen != null) "-q ${toString cfg.queuelen}";
11 # Duplicate code, also found in cron.nix. Needs deduplication.
14 SHELL=${pkgs.bash}/bin/bash
15 PATH=${config.system.path}/bin:${config.system.path}/sbin
16 ${optionalString (config.services.cron.mailto != null) ''
17 MAILTO="${config.services.cron.mailto}"
20 ${lib.concatStrings (map (job: job + "\n") config.services.cron.systemCronJobs)}
23 allowdeny = target: users:
24 { source = pkgs.writeText "fcron.${target}" (concatStringsSep "\n" users);
25 target = "fcron.${target}";
27 gid = config.ids.gids.fcron;
43 description = "Whether to enable the {command}`fcron` daemon.";
47 type = types.listOf types.str;
50 Users allowed to use fcrontab and fcrondyn (one name per
51 line, `all` for everyone).
56 type = types.listOf types.str;
58 description = "Users forbidden from using fcron.";
61 maxSerialJobs = mkOption {
64 description = "Maximum number of serial jobs which can run simultaneously.";
68 type = types.nullOr types.int;
70 description = "Number of jobs the serial queue and the lavg queue can contain.";
76 description = ''The "system" crontab contents.'';
85 config = mkIf cfg.enable {
87 services.fcron.systab = systemCronJobs;
89 environment.etc = listToAttrs
90 (map (x: { name = x.target; value = x; })
91 [ (allowdeny "allow" (cfg.allow))
92 (allowdeny "deny" cfg.deny)
93 # see man 5 fcron.conf
97 lib.hasAttr "sendmail" config.security.wrappers;
99 if isSendmailWrapped then "/run/wrappers/bin/sendmail"
100 else "${config.system.path}/bin/sendmail";
102 pkgs.writeText "fcron.conf" ''
103 fcrontabs = /var/spool/fcron
104 pidfile = /run/fcron.pid
105 fifofile = /run/fcron.fifo
106 fcronallow = /etc/fcron.allow
107 fcrondeny = /etc/fcron.deny
109 sendmail = ${sendmailPath}
110 editor = ${pkgs.vim}/bin/vim
112 target = "fcron.conf";
113 gid = config.ids.gids.fcron;
118 environment.systemPackages = [ pkgs.fcron ];
119 users.users.fcron = {
120 uid = config.ids.uids.fcron;
121 home = "/var/spool/fcron";
124 users.groups.fcron.gid = config.ids.gids.fcron;
126 security.wrappers = {
128 source = "${pkgs.fcron}/bin/fcrontab";
135 source = "${pkgs.fcron}/bin/fcrondyn";
142 source = "${pkgs.fcron}/bin/fcronsighup";
148 systemd.services.fcron = {
149 description = "fcron daemon";
150 wantedBy = [ "multi-user.target" ];
152 path = [ pkgs.fcron ];
159 --directory /var/spool/fcron
160 # load system crontab file
161 /run/wrappers/bin/fcrontab -u systab - < ${pkgs.writeText "systab" cfg.systab}
166 ExecStart = "${pkgs.fcron}/sbin/fcron -m ${toString cfg.maxSerialJobs} ${queuelen}";