1 { config, pkgs, lib, utils, ... }:
4 cfg = config.services.docuum;
5 inherit (lib) mkIf mkEnableOption mkOption getExe types optionals concatMap;
8 options.services.docuum = {
9 enable = mkEnableOption "docuum daemon";
11 threshold = mkOption {
12 description = "Threshold for deletion in bytes, like `10 GB`, `10 GiB`, `10GB` or percentage-based thresholds like `50%`";
19 description = "Sets the minimum age of images to be considered for deletion.";
20 type = types.nullOr types.str;
26 description = "Prevents deletion of images for which repository:tag matches the specified regex.";
27 type = types.listOf types.str;
29 example = [ "^my-image" ];
32 deletionChunkSize = mkOption {
33 description = "Removes specified quantity of images at a time.";
40 config = mkIf cfg.enable {
43 assertion = config.virtualisation.docker.enable;
44 message = "docuum requires docker on the host";
48 systemd.services.docuum = {
49 after = [ "docker.socket" ];
50 requires = [ "docker.socket" ];
51 wantedBy = [ "multi-user.target" ];
52 path = [ config.virtualisation.docker.package ];
53 environment.HOME = "/var/lib/docuum";
57 StateDirectory = "docuum";
58 SupplementaryGroups = [ "docker" ];
59 ExecStart = utils.escapeSystemdExecArgs ([
61 "--threshold" cfg.threshold
62 "--deletion-chunk-size" cfg.deletionChunkSize
63 ] ++ (concatMap (keep: [ "--keep" keep ]) cfg.keep)
64 ++ (optionals (cfg.minAge != null) [ "--min-age" cfg.minAge ])