summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAaron Andersen <aaron@fosslib.net>2018-08-25 18:08:24 -0400
committerAaron Andersen <aaron@fosslib.net>2018-08-25 18:08:24 -0400
commitfc03a9f5b7bdd839f9f51f0ec950ae53228643e4 (patch)
treed253001912e333a473a99a3f26d4b50b028a4840 /nixos
parent3d1331f438b536f65fa4f5a07cbcb9eaaae8ce2f (diff)
downloadnixlib-fc03a9f5b7bdd839f9f51f0ec950ae53228643e4.tar
nixlib-fc03a9f5b7bdd839f9f51f0ec950ae53228643e4.tar.gz
nixlib-fc03a9f5b7bdd839f9f51f0ec950ae53228643e4.tar.bz2
nixlib-fc03a9f5b7bdd839f9f51f0ec950ae53228643e4.tar.lz
nixlib-fc03a9f5b7bdd839f9f51f0ec950ae53228643e4.tar.xz
nixlib-fc03a9f5b7bdd839f9f51f0ec950ae53228643e4.tar.zst
nixlib-fc03a9f5b7bdd839f9f51f0ec950ae53228643e4.zip
initial work on incron service
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/monitoring/incron.nix73
2 files changed, 74 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 2846afea8fbc..4d83e10d0297 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -416,6 +416,7 @@
   ./services/monitoring/graphite.nix
   ./services/monitoring/hdaps.nix
   ./services/monitoring/heapster.nix
+  ./services/monitoring/incron.nix
   ./services/monitoring/longview.nix
   ./services/monitoring/monit.nix
   ./services/monitoring/munin.nix
diff --git a/nixos/modules/services/monitoring/incron.nix b/nixos/modules/services/monitoring/incron.nix
new file mode 100644
index 000000000000..8e312c65f93c
--- /dev/null
+++ b/nixos/modules/services/monitoring/incron.nix
@@ -0,0 +1,73 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+  cfg = config.services.incron;
+
+in
+
+{
+  options = {
+
+    services.incron = {
+
+      enable = mkOption {
+        type = types.bool;
+        default = false;
+        description = "Whether to enable the incron daemon.";
+      };
+
+      allow = mkOption {
+        type = types.nullOr (types.listOf types.str);
+        default = null;
+        description = "Users allowed to use incrontab.";
+      };
+
+      deny = mkOption {
+        type = types.nullOr (types.listOf types.str);
+        default = null;
+        description = "Users forbidden from using incrontab.";
+      };
+
+      systab = mkOption {
+        type = types.lines;
+        default = "";
+        description = "The system incrontab contents.";
+        example = ''
+          "/var/mail IN_CLOSE_WRITE abc $@/$#"
+          "/tmp IN_ALL_EVENTS efg $@/$# $&"
+        '';
+      };
+
+    };
+
+  };
+
+  config = mkIf cfg.enable {
+
+    environment.systemPackages = [ pkgs.incron ];
+
+    security.wrappers.incrontab.source = "${pkgs.incron}/bin/incrontab";
+
+    environment.etc."incron.d/system".text = "${cfg.systab}";
+    environment.etc."incron.allow" = mkIf (cfg.allow != null) {
+      text = "${concatStringsSep "\n" cfg.allow}";
+    };
+    environment.etc."incron.deny" = mkIf (cfg.deny != null) {
+      text = "${concatStringsSep "\n" cfg.deny}";
+    };
+
+    systemd.services.incron = {
+      description = "File system events scheduler";
+      wantedBy = [ "multi-user.target" ];
+      path = [ config.system.path ];
+      preStart = "mkdir -m 710 -p /var/spool/incron";
+      serviceConfig.Type = "forking";
+      serviceConfig.PIDFile = "/run/incrond.pid";
+      serviceConfig.ExecStart = "${pkgs.incron}/bin/incrond";
+    };
+  };
+
+}