summaryrefslogtreecommitdiff
path: root/nix/module.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix/module.nix')
-rw-r--r--nix/module.nix43
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
3with utils;
4with lib;
5
6let
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 };
33in {
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}