summary refs log tree commit diff
path: root/nixos/modules/services/networking/zerotierone.nix
blob: 886ea18d980958c05fbf44a023116881b9c97860 (plain) (blame)
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
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.zerotierone;
in
{
  options.services.zerotierone.enable = mkEnableOption "ZeroTierOne";
  
  config = mkIf cfg.enable {
    systemd.services.zerotierone = {
      description = "ZeroTierOne";
      path = [ pkgs.zerotierone ];
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];
      preStart =
        ''
        mkdir -p /var/lib/zerotier-one
        chmod 700 /var/lib/zerotier-one
        chown -R root:root /var/lib/zerotier-one
        '';
      serviceConfig = {
        Type = "forking";
        User = "root";
        PIDFile = "/var/lib/zerotier-one/zerotier-one.pid";
        ExecStart = "${pkgs.zerotierone}/bin/zerotier-one -d";
      };
    };
  environment.systemPackages = [ pkgs.zerotierone ];
  };
}