about summary refs log tree commit diff
path: root/nixos/modules/services/networking/twingate.nix
blob: 17140bffd218730f2f5d35cc9cf2baa64539a54b (plain) (blame)
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
28
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.twingate;

in {

  options.services.twingate = {
    enable = mkEnableOption (lib.mdDoc "Twingate Client daemon");
  };

  config = mkIf cfg.enable {

    networking.firewall.checkReversePath = lib.mkDefault false;
    networking.networkmanager.enable = true;

    environment.systemPackages = [ pkgs.twingate ]; # for the CLI
    systemd.packages = [ pkgs.twingate ];

    systemd.services.twingate.preStart = ''
      cp -r -n ${pkgs.twingate}/etc/twingate/. /etc/twingate/
    '';

    systemd.services.twingate.wantedBy = [ "multi-user.target" ];
  };
}