From cc0cd538e62ce5e220ae296e65342ba258d186f8 Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 14 Jul 2019 18:08:33 +0200 Subject: [PATCH] taskwarrior-sync: add service module --- modules/misc/news.nix | 8 ++++ modules/modules.nix | 1 + modules/services/taskwarrior-sync.nix | 59 +++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 modules/services/taskwarrior-sync.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 0af6963a..59f1726d 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1137,6 +1137,14 @@ in A new module is available: 'programs.broot'. ''; } + + { + time = "2019-07-17T19:30:29+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.taskwarrior-sync'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 2a3549d1..d5efe2d1 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -124,6 +124,7 @@ let (loadModule ./services/syncthing.nix { }) (loadModule ./services/taffybar.nix { }) (loadModule ./services/tahoe-lafs.nix { }) + (loadModule ./services/taskwarrior-sync.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/udiskie.nix { }) (loadModule ./services/unclutter.nix { }) (loadModule ./services/window-managers/awesome.nix { }) diff --git a/modules/services/taskwarrior-sync.nix b/modules/services/taskwarrior-sync.nix new file mode 100644 index 00000000..f92f532b --- /dev/null +++ b/modules/services/taskwarrior-sync.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.taskwarrior-sync; + +in + +{ + meta.maintainers = with maintainers; [ minijackson pacien ]; + + options.services.taskwarrior-sync = { + enable = mkEnableOption "Taskwarrior periodic sync"; + + frequency = mkOption { + type = types.str; + default = "*:0/5"; + description = '' + How often to run taskwarrior sync. This + value is passed to the systemd timer configuration as the + OnCalendar option. See + + systemd.time + 7 + + for more information about the format. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.taskwarrior-sync = { + Unit = { + Description = "Taskwarrior sync"; + PartOf = [ "network-online.target" ]; + }; + Service = { + CPUSchedulingPolicy = "idle"; + IOSchedulingClass = "idle"; + ExecStart = "${pkgs.taskwarrior}/bin/task synchronize"; + }; + }; + + systemd.user.timers.taskwarrior-sync = { + Unit = { + Description = "Taskwarrior periodic sync"; + }; + Timer = { + Unit = "taskwarrior-sync.service"; + OnCalendar = cfg.frequency; + }; + Install = { + WantedBy = [ "timers.target" ]; + }; + }; + }; +}