-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
services/vdirsyncer: init #3912
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,70 @@ | ||||||
{ pkgs, lib, config, ... }: | ||||||
with lib; | ||||||
let | ||||||
cfg = config.services.vdirsyncer; | ||||||
formatToUnknownFormat = settings: | ||||||
let | ||||||
quoteStr = s: ''"${s}"''; | ||||||
mkKeyValue = name: value: "${name} = ${mkValue value}"; | ||||||
mkValue = value: | ||||||
if builtins.isList value then | ||||||
"[${concatStringsSep ", " (map mkValue value)}]" | ||||||
else if builtins.isString value then | ||||||
quoteStr value | ||||||
else | ||||||
(toString value); | ||||||
mkSection = title: val: '' | ||||||
[${title}] | ||||||
${concatStringsSep "\n" (mapAttrsToList mkKeyValue val)} | ||||||
''; | ||||||
in concatStringsSep "\n" (mapAttrsToList mkSection settings); | ||||||
cfgFile = | ||||||
pkgs.writeText "vdirsyncer.conf" (formatToUnknownFormat cfg.settings); | ||||||
in { | ||||||
options.services.vdirsyncer = { | ||||||
enable = mkEnableOption "synchronization of calendars"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
settings = mkOption { type = types.attrs; }; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a description, default value and better type (see above) |
||||||
configFile = mkOption { | ||||||
type = types.path; | ||||||
default = cfgFile; | ||||||
}; | ||||||
onBootSec = mkOption { | ||||||
type = types.str; | ||||||
default = "15min"; | ||||||
}; | ||||||
onUnitActiveSec = mkOption { | ||||||
type = types.str; | ||||||
default = "30min"; | ||||||
}; | ||||||
Comment on lines
+27
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These need descriptions. I'd also get rid of |
||||||
}; | ||||||
|
||||||
config = mkIf cfg.enable { | ||||||
systemd.user.timers.vdirsyncer = { | ||||||
Unit = { Description = "Timer to synchronize calendars"; }; | ||||||
|
||||||
Timer = { | ||||||
OnBootSec = cfg.onBootSec; | ||||||
OnUnitActiveSec = cfg.onUnitActiveSec; | ||||||
}; | ||||||
|
||||||
Install.WantedBy = [ "timers.target" ]; | ||||||
}; | ||||||
|
||||||
systemd.user.services.vdirsyncer = { | ||||||
Unit = { | ||||||
Description = "Synchronize your calendars"; | ||||||
After = [ "network-online.target" ]; | ||||||
Wants = [ "network-online.target" ]; | ||||||
}; | ||||||
|
||||||
Install.WantedBy = [ "default.target" ]; | ||||||
|
||||||
Service = { | ||||||
ExecStart = "${pkgs.vdirsyncer}/bin/vdirsyncer -c ${cfgFile} sync"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably want to do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as mentioned here: #3982 (comment) we should probably do |
||||||
Restart = "on-failure"; | ||||||
Type = "oneshot"; | ||||||
RestartSec = 30; | ||||||
}; | ||||||
}; | ||||||
}; | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the format they use is basically INI but with JSON values... https://github.com/pimutils/vdirsyncer/blob/079a156bf82fe86173d0d05ec0937703b5c6a735/vdirsyncer/cli/config.py#L151
So like,