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 . vdirsyncer ; 8 9vdirsyncerOptions = [ ] 10++ optional ( cfg . verbosity != null ) "--verbosity ${ cfg . verbosity } " 11++ optional ( cfg . configFile != null ) "--config ${ cfg . configFile } " ; 12 13in { 14meta . maintainers = [ maintainers . pjones ]; 15 16options . services . vdirsyncer = { 17enable = mkEnableOption "vdirsyncer" ; 18 19package = mkOption { 20type = types . package ; 21default = pkgs . vdirsyncer ; 22defaultText = "pkgs.vdirsyncer" ; 23example = literalExpression "pkgs.vdirsyncer" ; 24description = "The package to use for the vdirsyncer binary." ; 25}; 26 27frequency = mkOption { 28type = types . str ; 29default = "*:0/5" ; 30description = '' 31How often to run vdirsyncer. This value is passed to the systemd 32timer configuration as the onCalendar option. See 33{manpage}`systemd.time(7)` 34for more information about the format. 35'' ; 36}; 37 38verbosity = mkOption { 39type = types . nullOr 40( types . enum [ "CRITICAL" "ERROR" "WARNING" "INFO" "DEBUG" ]); 41default = null ; 42description = '' 43Whether vdirsyncer should produce verbose output. 44'' ; 45}; 46 47configFile = mkOption { 48type = types . nullOr types . path ; 49default = null ; 50description = '' 51Optional configuration file to link to use instead of 52the default file ({file}`$XDG_CONFIG_HOME/vdirsyncer/config`). 53'' ; 54}; 55}; 56 57config = mkIf cfg . enable { 58systemd . user . services . vdirsyncer = { 59Unit = { 60Description = "vdirsyncer calendar&contacts synchronization" ; 61PartOf = [ "network-online.target" ]; 62}; 63 64Service = { 65Type = "oneshot" ; 66# TODO `vdirsyncer discover` 67ExecStart = let optStr = concatStringsSep " " vdirsyncerOptions ; 68in [ 69" ${ cfg . package } /bin/vdirsyncer ${ optStr } metasync" 70" ${ cfg . package } /bin/vdirsyncer ${ optStr } sync" 71]; 72}; 73}; 74 75systemd . user . timers . vdirsyncer = { 76Unit = { Description = "vdirsyncer calendar&contacts synchronization" ; }; 77 78Timer = { 79OnCalendar = cfg . frequency ; 80Unit = "vdirsyncer.service" ; 81}; 82 83Install = { WantedBy = [ "timers.target" ]; }; 84}; 85}; 86}