Skip to content

Commit

Permalink
nixos/services.fcron: remove with lib;
Browse files Browse the repository at this point in the history
  • Loading branch information
Stunkymonkey committed Dec 29, 2024
1 parent 4cff1f5 commit ed7294a
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions nixos/modules/services/scheduling/fcron.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@
pkgs,
...
}:

with lib;

let

cfg = config.services.fcron;

queuelen = optionalString (cfg.queuelen != null) "-q ${toString cfg.queuelen}";
queuelen = lib.optionalString (cfg.queuelen != null) "-q ${toString cfg.queuelen}";

# Duplicate code, also found in cron.nix. Needs deduplication.
systemCronJobs = ''
SHELL=${pkgs.bash}/bin/bash
PATH=${config.system.path}/bin:${config.system.path}/sbin
${optionalString (config.services.cron.mailto != null) ''
${lib.optionalString (config.services.cron.mailto != null) ''
MAILTO="${config.services.cron.mailto}"
''}
NIX_CONF_DIR=/etc/nix
${lib.concatStrings (map (job: job + "\n") config.services.cron.systemCronJobs)}
'';

allowdeny = target: users: {
source = pkgs.writeText "fcron.${target}" (concatStringsSep "\n" users);
source = pkgs.writeText "fcron.${target}" (lib.concatStringsSep "\n" users);
target = "fcron.${target}";
mode = "644";
gid = config.ids.gids.fcron;
Expand All @@ -41,41 +38,41 @@ in

services.fcron = {

enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable the {command}`fcron` daemon.";
};

allow = mkOption {
type = types.listOf types.str;
allow = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "all" ];
description = ''
Users allowed to use fcrontab and fcrondyn (one name per
line, `all` for everyone).
'';
};

deny = mkOption {
type = types.listOf types.str;
deny = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "Users forbidden from using fcron.";
};

maxSerialJobs = mkOption {
type = types.int;
maxSerialJobs = lib.mkOption {
type = lib.types.int;
default = 1;
description = "Maximum number of serial jobs which can run simultaneously.";
};

queuelen = mkOption {
type = types.nullOr types.int;
queuelen = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = "Number of jobs the serial queue and the lavg queue can contain.";
};

systab = mkOption {
type = types.lines;
systab = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''The "system" crontab contents.'';
};
Expand All @@ -85,11 +82,11 @@ in

###### implementation

config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {

services.fcron.systab = systemCronJobs;

environment.etc = listToAttrs (
environment.etc = lib.listToAttrs (
map
(x: {
name = x.target;
Expand Down

0 comments on commit ed7294a

Please sign in to comment.