gc
This commit is contained in:
parent
8231096aa8
commit
7e2a3961a8
22
mod.nix
22
mod.nix
@ -38,6 +38,24 @@ in
|
|||||||
type = with types; listOf path;
|
type = with types; listOf path;
|
||||||
default = [ ];
|
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 = {
|
options.programs.brownpaper = {
|
||||||
enable = mkEnableOption "brownpaper client";
|
enable = mkEnableOption "brownpaper client";
|
||||||
@ -72,6 +90,10 @@ in
|
|||||||
User = cfg.user;
|
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 [
|
environment.systemPackages = optionals cfgc.enable [
|
||||||
(pkgs.writeShellScriptBin "brownpaper" ''
|
(pkgs.writeShellScriptBin "brownpaper" ''
|
||||||
BROWNPAPER_ENDPOINT='${cfgc.endpoint}' ${(pkgs.callPackage ./. { inherit pkgs; src = ./.; }).client}/bin/brownpaper "$@"
|
BROWNPAPER_ENDPOINT='${cfgc.endpoint}' ${(pkgs.callPackage ./. { inherit pkgs; src = ./.; }).client}/bin/brownpaper "$@"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user