fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.3 KiB52 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.services.taskwarrior-sync;
8
9in {
10  meta.maintainers = with maintainers; [ minijackson pacien ];
11
12  options.services.taskwarrior-sync = {
13    enable = mkEnableOption "Taskwarrior periodic sync";
14
15    frequency = mkOption {
16      type = types.str;
17      default = "*:0/5";
18      description = ''
19        How often to run `taskwarrior sync`. This
20        value is passed to the systemd timer configuration as the
21        `OnCalendar` option. See
22        {manpage}`systemd.time(7)`
23        for more information about the format.
24      '';
25    };
26  };
27
28  config = mkIf cfg.enable {
29    assertions = [
30      (lib.hm.assertions.assertPlatform "services.taskwarrior-sync" pkgs
31        lib.platforms.linux)
32    ];
33
34    systemd.user.services.taskwarrior-sync = {
35      Unit = { Description = "Taskwarrior sync"; };
36      Service = {
37        CPUSchedulingPolicy = "idle";
38        IOSchedulingClass = "idle";
39        ExecStart = "${pkgs.taskwarrior}/bin/task synchronize";
40      };
41    };
42
43    systemd.user.timers.taskwarrior-sync = {
44      Unit = { Description = "Taskwarrior periodic sync"; };
45      Timer = {
46        Unit = "taskwarrior-sync.service";
47        OnCalendar = cfg.frequency;
48      };
49      Install = { WantedBy = [ "timers.target" ]; };
50    };
51  };
52}