nixos-config/modules/mullvad.nix
2019-09-25 20:47:27 +04:00

50 lines
1.1 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.networking.mullvad;
in {
###### interface
options = {
networking.mullvad = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
This option enables mullvad vpn daemon.
'';
};
enableOnBoot = mkOption {
type = types.bool;
default = true;
description = ''
When enabled mullvad daemon is started on boot.
'';
};
};
};
###### implementation
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.mullvad-vpn ];
systemd.services.mullvad-daemon = {
description = "Mullvad VPN daemon";
wantedBy = optional cfg.enableOnBoot "multi-user.target";
wants = [ "network.target" ];
after = [
"network-online.target"
"NetworkManager.service"
"systemd-resolved.service"
];
startLimitIntervalSec = 20;
serviceConfig = {
ExecStart = "${pkgs.mullvad-vpn}/bin/mullvad-daemon -v --disable-stdout-timestamps";
Restart = "always";
RestartSec = 1;
};
};
};
}