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.
|
2021-05-06 12:23:54 +01:00
|
|
|
This sets <option>networking.firewall.checkReversePath</option> to "loose", which might be undesirable for security.
|
2019-10-08 18:01:14 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2021-05-06 12:23:54 +01:00
|
|
|
# See https://github.com/NixOS/nixpkgs/issues/113589
|
|
|
|
networking.firewall.checkReversePath = "loose";
|
|
|
|
|
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 = [
|
2021-04-08 12:33:09 +01:00
|
|
|
pkgs.iproute2
|
2019-10-08 18:01:14 +01:00
|
|
|
# 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;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-05-06 12:23:54 +01:00
|
|
|
meta.maintainers = with maintainers; [ ymarkus ];
|
2019-10-08 18:01:14 +01:00
|
|
|
}
|