From 82a091e196a9a6cb132ca20aea16a3dc43971add Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 18 Apr 2018 14:47:59 +0200 Subject: rollingDirectories --- nix/module.nix | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'nix/module.nix') 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 @@ -{ ... }: +{ 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; + }; + + monitorTimeout = mkOption { + type = with types; nullOr ints.positive; + default = 3600; + }; + }; + }; + + dirService = dCfg: with dCfg; nameValuePair ("rolling-directory@" + escapeSystemdPath path) { + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + ExecStart = let + args = [ path (toString maxSize) ] + optional (monitorTimeout != null) monitorTimeout; + in "${pkgs.rolling-directory}/bin/rolling-directory ${escapeShellArgs args}"; + }; + }; +in { + options = { + services.rollingDirectories = mkOption { + type = with types; listOf (submodule dirConfig); + default = []; + }; + }; -{ config = { nixpkgs.config.packageOverrides = import ./default.nix; + + systemd.services = genAttrs config.rollingDirectories dirService; }; } -- cgit v1.2.3