diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-18 14:47:59 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-18 14:47:59 +0200 |
commit | 82a091e196a9a6cb132ca20aea16a3dc43971add (patch) | |
tree | 10daf95745aa0d90dfb18876320450ba126ce094 | |
parent | d24dede086a44c5a771ff2ad6484137e3b466f4d (diff) | |
download | utils-82a091e196a9a6cb132ca20aea16a3dc43971add.tar utils-82a091e196a9a6cb132ca20aea16a3dc43971add.tar.gz utils-82a091e196a9a6cb132ca20aea16a3dc43971add.tar.bz2 utils-82a091e196a9a6cb132ca20aea16a3dc43971add.tar.xz utils-82a091e196a9a6cb132ca20aea16a3dc43971add.zip |
rollingDirectories
-rw-r--r-- | nix/module.nix | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/nix/module.nix b/nix/module.nix index c70d7e0..112d95e 100644 --- a/nix/module.nix +++ b/nix/module.nix | |||
@@ -1,7 +1,46 @@ | |||
1 | { ... }: | 1 | { config, pkgs, lib, utils, ... }: |
2 | |||
3 | with utils; | ||
4 | with lib; | ||
5 | |||
6 | let | ||
7 | dirConfig = { | ||
8 | options = { | ||
9 | path = mkOption { | ||
10 | type = types.path; | ||
11 | }; | ||
12 | |||
13 | maxSize = mkOption { | ||
14 | type = with types; either ints.positive str; | ||
15 | }; | ||
16 | |||
17 | monitorTimeout = mkOption { | ||
18 | type = with types; nullOr ints.positive; | ||
19 | default = 3600; | ||
20 | }; | ||
21 | }; | ||
22 | }; | ||
23 | |||
24 | dirService = dCfg: with dCfg; nameValuePair ("rolling-directory@" + escapeSystemdPath path) { | ||
25 | wantedBy = [ "multi-user.target" ]; | ||
26 | |||
27 | serviceConfig = { | ||
28 | ExecStart = let | ||
29 | args = [ path (toString maxSize) ] + optional (monitorTimeout != null) monitorTimeout; | ||
30 | in "${pkgs.rolling-directory}/bin/rolling-directory ${escapeShellArgs args}"; | ||
31 | }; | ||
32 | }; | ||
33 | in { | ||
34 | options = { | ||
35 | services.rollingDirectories = mkOption { | ||
36 | type = with types; listOf (submodule dirConfig); | ||
37 | default = []; | ||
38 | }; | ||
39 | }; | ||
2 | 40 | ||
3 | { | ||
4 | config = { | 41 | config = { |
5 | nixpkgs.config.packageOverrides = import ./default.nix; | 42 | nixpkgs.config.packageOverrides = import ./default.nix; |
43 | |||
44 | systemd.services = genAttrs config.rollingDirectories dirService; | ||
6 | }; | 45 | }; |
7 | } | 46 | } |