2019-10-08 18:01:14 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.mullvad-vpn;
|
|
|
|
in
|
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
options.services.mullvad-vpn.enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
This option enables Mullvad VPN daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
boot.kernelModules = [ "tun" ];
|
|
|
|
|
2020-11-17 01:23:55 +00:00
|
|
|
# mullvad-daemon writes to /etc/iproute2/rt_tables
|
|
|
|
networking.iproute2.enable = true;
|
|
|
|
|
2019-10-08 18:01:14 +01:00
|
|
|
systemd.services.mullvad-daemon = {
|
|
|
|
description = "Mullvad VPN daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
wants = [ "network.target" ];
|
|
|
|
after = [
|
|
|
|
"network-online.target"
|
|
|
|
"NetworkManager.service"
|
|
|
|
"systemd-resolved.service"
|
|
|
|
];
|
|
|
|
path = [
|
|
|
|
pkgs.iproute
|
|
|
|
# Needed for ping
|
|
|
|
"/run/wrappers"
|
|
|
|
];
|
2020-09-09 08:31:27 +01:00
|
|
|
startLimitBurst = 5;
|
|
|
|
startLimitIntervalSec = 20;
|
2019-10-08 18:01:14 +01:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.mullvad-vpn}/bin/mullvad-daemon -v --disable-stdout-timestamps";
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = 1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = [ maintainers.xfix ];
|
|
|
|
}
|