{ 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; }; }