nixos/services.incron: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-30 00:46:58 +02:00
parent baece5fb08
commit 5b48323837

View File

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.incron; cfg = config.services.incron;
@ -14,8 +10,8 @@ in
services.incron = { services.incron = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable the incron daemon. Whether to enable the incron daemon.
@ -24,8 +20,8 @@ in
''; '';
}; };
allow = mkOption { allow = lib.mkOption {
type = types.nullOr (types.listOf types.str); type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null; default = null;
description = '' description = ''
Users allowed to use incrontab. Users allowed to use incrontab.
@ -37,14 +33,14 @@ in
''; '';
}; };
deny = mkOption { deny = lib.mkOption {
type = types.nullOr (types.listOf types.str); type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null; default = null;
description = "Users forbidden from using incrontab."; description = "Users forbidden from using incrontab.";
}; };
systab = mkOption { systab = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = "The system incrontab contents."; description = "The system incrontab contents.";
example = '' example = ''
@ -53,10 +49,10 @@ in
''; '';
}; };
extraPackages = mkOption { extraPackages = lib.mkOption {
type = types.listOf types.package; type = lib.types.listOf lib.types.package;
default = []; default = [];
example = literalExpression "[ pkgs.rsync ]"; example = lib.literalExpression "[ pkgs.rsync ]";
description = "Extra packages available to the system incrontab."; description = "Extra packages available to the system incrontab.";
}; };
@ -64,9 +60,9 @@ in
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
warnings = optional (cfg.allow != null && cfg.deny != null) warnings = lib.optional (cfg.allow != null && cfg.deny != null)
"If `services.incron.allow` is set then `services.incron.deny` will be ignored."; "If `services.incron.allow` is set then `services.incron.deny` will be ignored.";
environment.systemPackages = [ pkgs.incron ]; environment.systemPackages = [ pkgs.incron ];
@ -83,11 +79,11 @@ in
mode = "0444"; mode = "0444";
text = cfg.systab; text = cfg.systab;
}; };
environment.etc."incron.allow" = mkIf (cfg.allow != null) { environment.etc."incron.allow" = lib.mkIf (cfg.allow != null) {
text = concatStringsSep "\n" cfg.allow; text = lib.concatStringsSep "\n" cfg.allow;
}; };
environment.etc."incron.deny" = mkIf (cfg.deny != null) { environment.etc."incron.deny" = lib.mkIf (cfg.deny != null) {
text = concatStringsSep "\n" cfg.deny; text = lib.concatStringsSep "\n" cfg.deny;
}; };
systemd.services.incron = { systemd.services.incron = {