summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/misc/dump1090-fa.nix
blob: 91f60f2d1d1f48b92ec27afd05bad25d43be02c1 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{
  pkgs,
  config,
  lib,
  ...
}:
let
  cfg = config.services.dump1090-fa;
  inherit (lib) mkOption types;
in
{
  options.services.dump1090-fa = {
    enable = lib.mkEnableOption "dump1090-fa";

    package = lib.mkPackageOption pkgs "dump1090-fa" { };

    extraArgs = mkOption {
      type = types.listOf types.str;
      default = [ ];
      description = "Additional passed arguments";
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.dump1090-fa = {
      description = "dump1090 ADS-B receiver (FlightAware customization)";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];

      serviceConfig = {
        ExecStart = lib.escapeShellArgs (
          [
            (lib.getExe cfg.package)
            "--net"
            "--write-json"
            "%t/dump1090-fa"
          ]
          ++ cfg.extraArgs
        );
        DynamicUser = true;
        SupplementaryGroups = "plugdev";
        RuntimeDirectory = "dump1090-fa";
        WorkingDirectory = "%t/dump1090-fa";
        RuntimeDirectoryMode = 755;
        PrivateNetwork = true;
        LockPersonality = true;
        MemoryDenyWriteExecute = true;
        NoNewPrivileges = true;
        PrivateMounts = true;
        PrivateTmp = true;
        PrivateUsers = true;
        ProtectClock = true;
        ProtectHome = true;
        ProtectKernelLogs = true;
        ProtectKernelModules = true;
        ProtectKernelTunables = true;
        ProtectProc = "invisible";
        ProcSubset = "pid";
        ProtectSystem = "strict";
        ProtectHostname = true;
        RestrictSUIDSGID = true;
        RestrictNamespaces =
          "~"
          + (lib.concatStringsSep " " [
            "cgroup"
            "ipc"
            "net"
            "mnt"
            "pid"
            "user"
            "uts"
          ]);
        CapabilityBoundingSet = [
          "~CAP_AUDIT_CONTROL"
          "~CAP_AUDIT_READ"
          "~CAP_AUDIT_WRITE"
          "~CAP_KILL"
          "~CAP_MKNOD"
          "~CAP_NET_BIND_SERVICE"
          "~CAP_NET_BROADCAST"
          "~CAP_NET_ADMIN"
          "~CAP_NET_RAW"
          "~CAP_SYS_RAWIO"
          "~CAP_SYS_MODULE"
          "~CAP_SYS_PTRACE"
          "~CAP_SYS_TIME"
          "~CAP_SYS_NICE"
          "~CAP_SYS_RESOURCE"
          "~CAP_CHOWN"
          "~CAP_FSETID"
          "~CAP_SETUID"
          "~CAP_SETGID"
          "~CAP_SETPCAP"
          "~CAP_SETFCAP"
          "~CAP_DAC_OVERRIDE"
          "~CAP_DAC_READ_SEARCH"
          "~CAP_FOWNER"
          "~CAP_IPC_OWNER"
          "~CAP_IPC_LOCK"
          "~CAP_SYS_BOOT"
          "~CAP_SYS_ADMIN"
          "~CAP_MAC_ADMIN"
          "~CAP_MAC_OVERRIDE"
          "~CAP_SYS_CHROOT"
          "~CAP_BLOCK_SUSPEND"
          "~CAP_WAKE_ALARM"
          "~CAP_LEASE"
          "~CAP_SYS_PACCT"
        ];
        SystemCallFilter = [
          "~@clock"
          "~@debug"
          "~@module"
          "~@mount"
          "~@raw-io"
          "~@reboot"
          "~@swap"
          "~@privileged"
          "~@resources"
          "~@cpu-emulation"
          "~@obsolete"
        ];
        RestrictAddressFamilies = [ "~AF_PACKET" ];
        ProtectControlGroups = true;
        UMask = "0022";
        SystemCallArchitectures = "native";
      };
    };
  };

  meta = {
    maintainers = with lib.maintainers; [ aciceri ];
    doc = ./dump1090-fa.md;
  };
}