1 { config, lib, pkgs, ... }:
3 cfg = config.services.mullvad-vpn;
7 options.services.mullvad-vpn = {
11 description = lib.mdDoc ''
12 This option enables Mullvad VPN daemon.
13 This sets {option}`networking.firewall.checkReversePath` to "loose", which might be undesirable for security.
19 default = pkgs.mullvad;
20 defaultText = literalExpression "pkgs.mullvad";
21 description = lib.mdDoc ''
22 The Mullvad package to use. `pkgs.mullvad` only provides the CLI tool, `pkgs.mullvad-vpn` provides both the CLI and the GUI.
27 config = mkIf cfg.enable {
28 boot.kernelModules = [ "tun" ];
30 # mullvad-daemon writes to /etc/iproute2/rt_tables
31 networking.iproute2.enable = true;
33 # See https://github.com/NixOS/nixpkgs/issues/113589
34 networking.firewall.checkReversePath = "loose";
36 systemd.services.mullvad-daemon = {
37 description = "Mullvad VPN daemon";
38 wantedBy = [ "multi-user.target" ];
39 wants = [ "network.target" ];
41 "network-online.target"
42 "NetworkManager.service"
43 "systemd-resolved.service"
51 startLimitIntervalSec = 20;
53 ExecStart = "${cfg.package}/bin/mullvad-daemon -v --disable-stdout-timestamps";
60 meta.maintainers = with maintainers; [ patricksjackson ymarkus ];