2015-06-07 05:10:52 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.zerotierone;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.zerotierone.enable = mkEnableOption "ZeroTierOne";
|
2016-08-31 11:39:55 +01:00
|
|
|
options.services.zerotierone.package = mkOption {
|
|
|
|
default = pkgs.zerotierone;
|
|
|
|
defaultText = "pkgs.zerotierone";
|
|
|
|
type = types.package;
|
|
|
|
description = ''
|
|
|
|
ZeroTier One package to use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-06-07 05:10:52 +01:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.zerotierone = {
|
|
|
|
description = "ZeroTierOne";
|
2016-08-31 11:39:55 +01:00
|
|
|
path = [ cfg.package ];
|
2015-06-07 05:10:52 +01:00
|
|
|
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 = {
|
2016-08-31 11:39:55 +01:00
|
|
|
ExecStart = "${cfg.package}/bin/zerotier-one";
|
2016-02-19 22:56:19 +00:00
|
|
|
Restart = "always";
|
|
|
|
KillMode = "process";
|
2015-06-07 05:10:52 +01:00
|
|
|
};
|
|
|
|
};
|
2016-07-23 20:02:57 +01:00
|
|
|
|
|
|
|
# ZeroTier does not issue DHCP leases, but some strangers might...
|
|
|
|
networking.dhcpcd.denyInterfaces = [ "zt0" ];
|
|
|
|
|
2016-08-31 11:39:55 +01:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
2015-06-07 05:10:52 +01:00
|
|
|
};
|
|
|
|
}
|