summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nix/module.nix14
-rw-r--r--nix/rolling-directory.nix2
-rw-r--r--rolling-directory17
3 files changed, 25 insertions, 8 deletions
diff --git a/nix/module.nix b/nix/module.nix
index 10c68ff..3263401 100644
--- a/nix/module.nix
+++ b/nix/module.nix
@@ -14,9 +14,14 @@ let
14 type = with types; either ints.positive str; 14 type = with types; either ints.positive str;
15 }; 15 };
16 16
17 minSleep = mkOption {
18 type = with types; nullOr ints.positive;
19 default = 3600;
20 };
21
17 monitorTimeout = mkOption { 22 monitorTimeout = mkOption {
18 type = with types; nullOr ints.positive; 23 type = with types; nullOr ints.positive;
19 default = 3600; 24 default = 3600 * 24;
20 }; 25 };
21 }; 26 };
22 }; 27 };
@@ -25,8 +30,11 @@ let
25 wantedBy = [ "multi-user.target" ]; 30 wantedBy = [ "multi-user.target" ];
26 31
27 serviceConfig = { 32 serviceConfig = {
28 ExecStart = '' 33 ExecStart = let
29 ${pkgs.rolling-directory}/bin/rolling-directory %I ${toString dCfg.maxSize} monitor ${optionalString (dCfg.monitorTimeout != null) (toString dCfg.monitorTimeout)} 34 extraArgs = optionals (dCfg.monitorTimeout != null) ["-t" (toString dCfg.monitorTimeout)]
35 + optionals (dCfg.minSleep != null) ["-s" (toString dCfg.minSleep)];
36 in ''
37 ${pkgs.rolling-directory}/bin/rolling-directory %I ${toString dCfg.maxSize} monitor ${escapeShellArgs extraArgs}
30 ''; 38 '';
31 }; 39 };
32 }; 40 };
diff --git a/nix/rolling-directory.nix b/nix/rolling-directory.nix
index bb5dd53..4093c36 100644
--- a/nix/rolling-directory.nix
+++ b/nix/rolling-directory.nix
@@ -4,7 +4,7 @@
4 4
5stdenv.mkDerivation rec { 5stdenv.mkDerivation rec {
6 name = "rolling-directory-${version}"; 6 name = "rolling-directory-${version}";
7 version = "0.2"; 7 version = "0.3";
8 src = ../rolling-directory; 8 src = ../rolling-directory;
9 9
10 phases = [ "buildPhase" "installPhase" ]; 10 phases = [ "buildPhase" "installPhase" ];
diff --git a/rolling-directory b/rolling-directory
index d85f8b7..ce97021 100644
--- a/rolling-directory
+++ b/rolling-directory
@@ -33,16 +33,25 @@ case "${1}" in
33 monitor) 33 monitor)
34 shift 34 shift
35 35
36 sleep=""
36 typeset -a inotifyExtra 37 typeset -a inotifyExtra
37 inotifyExtra=() 38 inotifyExtra=()
38 39
39 if [[ "${1}" = <-> ]]; then 40 while getopts 's:t:' opt; do
40 inotifyExtra=(-t "${1}") 41 case "${opt}" in
41 shift 42 s)
42 fi 43 [[ "${OPTARG}" = <-> ]] || exit 2
44 sleep=${OPTARG}
45 ;;
46 t)
47 [[ "${OPTARG}" = <-> ]] || exit 2
48 inotifyExtra+=(-t "${OPTARG}")
49 esac
50 done
43 51
44 while 52 while
45 resize 53 resize
54 [[ -n "$sleep" ]] && sleep ${sleep}
46 inotifywait -qq -r ${dir} ${inotifyExtra} \ 55 inotifywait -qq -r ${dir} ${inotifyExtra} \
47 -e modify \ 56 -e modify \
48 -e close_write \ 57 -e close_write \