blob: 40082b1542fc98469fb1b1b6083ac837dc72e011 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
{ config, pkgs, lib, utils, ... }:
with utils;
with lib;
let
dirConfig = {
options = {
path = mkOption {
type = types.path;
};
maxSize = mkOption {
type = with types; either ints.positive str;
};
minSleep = mkOption {
type = with types; nullOr ints.positive;
default = 3600;
};
monitorTimeout = mkOption {
type = with types; nullOr ints.positive;
default = 3600 * 24;
};
};
};
dirService = dCfg: nameValuePair ("rolling-directory@" + escapeSystemdPath dCfg.path) {
wantedBy = [ "multi-user.target" ];
path = with pkgs; [ rolling-directory ];
script = let
args = [ dCfg.path dCfg.maxSize "monitor" ]
++ optionals (dCfg.monitorTimeout != null) ["-t" dCfg.monitorTimeout]
++ optionals (dCfg.minSleep != null) ["-s" dCfg.minSleep];
in ''
exec -- rolling-directory ${escapeShellArgs args}
'';
};
in {
options = {
services.rollingDirectories = mkOption {
type = with types; listOf (submodule dirConfig);
default = [];
};
programs.recv.enable = mkEnableOption "the ‘recv’ program";
};
config = {
nixpkgs.overlays = [ (import ./default.nix) ];
systemd.services = listToAttrs (map dirService config.services.rollingDirectories);
security.wrappers = mkIf config.programs.recv.enable {
recv.source = "${pkgs.recv}/bin/recv";
};
};
}
|