summaryrefslogtreecommitdiffstats
path: root/makefu/3modules/taskserver.nix
blob: 41247fff3a48dea195c7173a7345cef8dea46915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ config, lib, pkgs, ... }:

with config.krebs.lib;
let
  cfg = config.makefu.taskserver;

  out = {
    options.makefu.taskserver = api;
    config = lib.mkIf cfg.enable imp;
  };

  api = {
    enable = mkEnableOption "taskserver";

    workingDir = mkOption {
      type = types.str;
      default = "/var/lib/taskserver";
    };

    package = mkOption {
      type = types.package;
      default = pkgs.taskserver;
    };


  };

  imp = {
    environment.systemPackages = [ cfg.package ];
    systemd.services.taskserver = {
      description = "taskd server";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];
      restartIfChanged = true;
      unitConfig = {
        Documentation = "http://taskwarrior.org/docs/#taskd" ;
        # https://taskwarrior.org/docs/taskserver/configure.html
        ConditionPathExists = "${cfg.workingDir}/config";
      };
      serviceConfig = {
        Type = "simple";
        ExecStart = "${cfg.package}/bin/taskd server --data ${cfg.workingDir}";
        WorkingDirectory = cfg.workingDir;
        PrivateTmp = true;
        InaccessibleDirectories = "/home /boot /opt /mnt /media";
        User = "taskd";
      };
    };

    users.users.taskd = {
      uid = genid "taskd";
      home = cfg.workingDir;
      createHome = true;
    };
    users.groups.taskd.gid = genid "taskd";
  };

in
out