Home

infra @17cae734b86425c0ca38cd2d7d66d1d1008c6b17 - refs - log -
-
https://git.jolheiser.com/infra.git
My NixOS infrastructure
infra / gunpowder / services / mullvad.nix
- raw -
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{ lib, config, ... }:
let
  enable = true;
in
lib.mkIf enable {
  age.secrets.mullvad.file = ../../secrets/mullvad.age;

  services.mullvad-vpn.enable = true;

  systemd.services.mullvad-provision = {
    description = "Log in to Mullvad and keep it connected";
    wantedBy = [ "multi-user.target" ];
    after = [ "mullvad-daemon.service" ];
    requires = [ "mullvad-daemon.service" ];
    path = [ config.services.mullvad-vpn.package ];
    serviceConfig = {
      Type = "oneshot";
      RemainAfterExit = true;
    };
    script = ''
      until mullvad status >/dev/null 2>&1; do sleep 1; done
      mullvad account login "$(cat ${config.age.secrets.mullvad.path})"
      mullvad auto-connect set on
      mullvad connect
    '';
  };
}