changes as per requested by @aszlig

This commit is contained in:
Aaron Andersen 2018-08-31 02:52:49 +00:00
parent 7bc2a0dd64
commit d7d7533c18
2 changed files with 13 additions and 16 deletions

View File

@ -20,7 +20,7 @@ in
description = '' description = ''
Whether to enable the incron daemon. Whether to enable the incron daemon.
Note that commands run under incrontab only support common Nix profiles for the PATH provided variable. Note that commands run under incrontab only support common Nix profiles for the <envar>PATH</envar> provided variable.
''; '';
}; };
@ -31,7 +31,7 @@ in
Users allowed to use incrontab. Users allowed to use incrontab.
If empty then no user will be allowed to have their own incrontab. If empty then no user will be allowed to have their own incrontab.
If null then will defer to <option>deny</option>. If <literal>null</literal> then will defer to <option>deny</option>.
If both <option>allow</option> and <option>deny</option> are null If both <option>allow</option> and <option>deny</option> are null
then all users will be allowed to have their own incrontab. then all users will be allowed to have their own incrontab.
''; '';
@ -48,15 +48,15 @@ in
default = ""; default = "";
description = "The system incrontab contents."; description = "The system incrontab contents.";
example = '' example = ''
"/var/mail IN_CLOSE_WRITE abc $@/$#" /var/mail IN_CLOSE_WRITE abc $@/$#
"/tmp IN_ALL_EVENTS efg $@/$# $&" /tmp IN_ALL_EVENTS efg $@/$# $&
''; '';
}; };
extraPackages = mkOption { extraPackages = mkOption {
type = types.listOf types.package; type = types.listOf types.package;
default = []; default = [];
example = "[ pkgs.rsync ];"; example = literalExample "[ pkgs.rsync ]";
description = "Extra packages available to the system incrontab."; description = "Extra packages available to the system incrontab.";
}; };
@ -66,11 +66,8 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [ warnings = optional (cfg.allow != null && cfg.deny != null)
{ assertion = cfg.allow != null -> cfg.deny == null; ''If `services.incron.allow` is set then `services.incron.deny` will be ignored.'';
message = "If `services.incron.allow` is set then `services.incron.deny` will be ignored.";
}
];
environment.systemPackages = [ pkgs.incron ]; environment.systemPackages = [ pkgs.incron ];
@ -79,22 +76,22 @@ in
# incron won't read symlinks # incron won't read symlinks
environment.etc."incron.d/system" = { environment.etc."incron.d/system" = {
mode = "0444"; mode = "0444";
text = ${cfg.systab}; text = cfg.systab;
}; };
environment.etc."incron.allow" = mkIf (cfg.allow != null) { environment.etc."incron.allow" = mkIf (cfg.allow != null) {
text = ${concatStringsSep "\n" cfg.allow}; text = concatStringsSep "\n" cfg.allow;
}; };
environment.etc."incron.deny" = mkIf (cfg.deny != null) { environment.etc."incron.deny" = mkIf (cfg.deny != null) {
text = ${concatStringsSep "\n" cfg.deny}; text = concatStringsSep "\n" cfg.deny;
}; };
systemd.services.incron = { systemd.services.incron = {
description = "File system events scheduler"; description = "File System Events Scheduler";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
path = cfg.extraPackages; path = cfg.extraPackages;
preStart = "mkdir -m 710 -p /var/spool/incron";
serviceConfig.Type = "forking"; serviceConfig.Type = "forking";
serviceConfig.PIDFile = "/run/incrond.pid"; serviceConfig.PIDFile = "/run/incrond.pid";
serviceConfig.ExecStartPre = "${pkgs.coreutils}/bin/mkdir -m 710 -p /var/spool/incron";
serviceConfig.ExecStart = "${pkgs.incron}/bin/incrond"; serviceConfig.ExecStart = "${pkgs.incron}/bin/incrond";
}; };
}; };

View File

@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
''; '';
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "A daemon which monitors filesystem events and executes commands defined in system and user tables"; description = "A cron-like daemon which handles filesystem events.";
homepage = https://github.com/ar-/incron; homepage = https://github.com/ar-/incron;
license = licenses.gpl2; license = licenses.gpl2;
maintainers = [ maintainers.aanderse ]; maintainers = [ maintainers.aanderse ];