summaryrefslogtreecommitdiffstats
path: root/makefu/3modules/opentracker.nix
blob: 6c65b82b6da2185c1bfaca7aa18b50136467bebc (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
{ config, lib, pkgs, ... }:

with import <stockholm/lib>;
let
  cfg = config.makefu.opentracker;

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

  api = {
    enable = mkEnableOption "opentracker";

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

    args = mkOption {
      type = types.separatedString;
      description = ''
        see https://erdgeist.org/arts/software/opentracker/ for all params
      '';
      default = "";
    };

    user = mkOption {
      description = ''
        user which will run opentracker. by default opentracker drops all
        privileges and runs in chroot after starting up as root.
      '';
      type = types.str;
      default = "root";
    };
  };

  imp = {
    systemd.services.opentracker = {
      description = "opentracker server";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];
      restartIfChanged = true;
      serviceConfig = {
        Type = "simple";
        ExecStart = "${cfg.package}/bin/opentracker ${cfg.args}";
        PrivateTmp = true;
        WorkingDirectory = "/tmp";
        User = "${cfg.user}";
      };
    };
  };
in
out