at 24.11-pre 1.2 kB view raw
1{ config, pkgs, lib, utils, ... }: 2 3let 4 cfg = config.services.docuum; 5 inherit (lib) mkIf mkEnableOption mkOption getExe types; 6in 7{ 8 options.services.docuum = { 9 enable = mkEnableOption "docuum daemon"; 10 11 threshold = mkOption { 12 description = "Threshold for deletion in bytes, like `10 GB`, `10 GiB`, `10GB` or percentage-based thresholds like `50%`"; 13 type = types.str; 14 default = "10 GB"; 15 example = "50%"; 16 }; 17 }; 18 19 config = mkIf cfg.enable { 20 assertions = [ 21 { 22 assertion = config.virtualisation.docker.enable; 23 message = "docuum requires docker on the host"; 24 } 25 ]; 26 27 systemd.services.docuum = { 28 after = [ "docker.socket" ]; 29 requires = [ "docker.socket" ]; 30 wantedBy = [ "multi-user.target" ]; 31 path = [ config.virtualisation.docker.package ]; 32 environment.HOME = "/var/lib/docuum"; 33 34 serviceConfig = { 35 DynamicUser = true; 36 StateDirectory = "docuum"; 37 SupplementaryGroups = [ "docker" ]; 38 ExecStart = utils.escapeSystemdExecArgs [ 39 (getExe pkgs.docuum) 40 "--threshold" cfg.threshold 41 ]; 42 }; 43 }; 44 }; 45}