fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . getmail ; 8 9accounts = 10filter ( a :a . getmail . enable ) ( attrValues config . accounts . . accounts ); 11 12# Note: The getmail service does not expect a path, but just the filename! 13renderConfigFilepath = a : 14if a . primary then "getmailrc" else "getmail ${ a . name } " ; 15configFiles = 16concatMapStringsSep " " ( a :" --rcfile ${ renderConfigFilepath a } " ) accounts ; 17in { 18options = { 19services . getmail = { 20enable = mkEnableOption 21"the getmail systemd service to automatically retrieve mail" ; 22 23frequency = mkOption { 24type = types . str ; 25default = "*:0/5" ; 26example = "hourly" ; 27description = '' 28The refresh frequency. Check `man systemd.time` for 29more information on the syntax. If you use a gpg-agent in 30combination with the passwordCommand, keep the poll 31frequency below the cache-ttl value (as set by the 32`default`) to avoid pinentry asking 33permanently for a password. 34'' ; 35}; 36}; 37}; 38 39config = mkIf cfg . enable { 40assertions = [ 41( lib . hm . assertions . assertPlatform "services.getmail" pkgs 42lib . platforms . linux ) 43]; 44 45systemd . user . services . getmail = { 46Unit = { Description = "getmail email fetcher" ; }; 47Service = { ExecStart = " ${ pkgs . getmail6 } /bin/getmail ${ configFiles } " ; }; 48}; 49 50systemd . user . timers . getmail = { 51Unit = { Description = "getmail email fetcher" ; }; 52Timer = { 53OnCalendar = " ${ cfg . frequency } " ; 54Unit = "getmail.service" ; 55}; 56Install = { WantedBy = [ "timers.target" ]; }; 57}; 58 59}; 60}