This commit is contained in:
shimun 2020-12-22 20:05:29 +01:00
parent 8231096aa8
commit 7e2a3961a8
Signed by: shimun
GPG Key ID: E81D8382DC2F971B

22
mod.nix
View File

@ -38,6 +38,24 @@ in
type = with types; listOf path;
default = [ ];
};
gc = {
enable = mkEnableOption "delete old snippets";
dates = mkOption {
type = types.str;
default = "00:00";
description = ''
Specification (in the format described by
<citerefentry><refentrytitle>systemd.time</refentrytitle>
<manvolnum>7</manvolnum></citerefentry>) of the time at
which the garbage collector will run.
'';
};
maxAge = mkOption {
type = types.ints.positive;
default = 60 * 24 * 30;
description = "maximum age in minutes after which snippets will be garbage collected. Defaults to 30 days";
};
};
};
options.programs.brownpaper = {
enable = mkEnableOption "brownpaper client";
@ -72,6 +90,10 @@ in
User = cfg.user;
};
};
systemd.services.brownpaper-gc = mkIf (cfg.enable && cfg.gc.enable) {
startAt = cfg.gc.dates;
script = "${pkgs.findutils}/bin/find ${cfg.dataDir} -maxdepth 1 -type f -mmin +${toString cfg.gc.maxAge} -delete";
};
environment.systemPackages = optionals cfgc.enable [
(pkgs.writeShellScriptBin "brownpaper" ''
BROWNPAPER_ENDPOINT='${cfgc.endpoint}' ${(pkgs.callPackage ./. { inherit pkgs; src = ./.; }).client}/bin/brownpaper "$@"