2022-11-04 12:36:45 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.twingate;
|
2023-07-07 16:50:29 +00:00
|
|
|
in
|
|
|
|
{
|
2022-11-04 12:36:45 +00:00
|
|
|
options.services.twingate = {
|
2023-07-07 16:50:29 +00:00
|
|
|
enable = lib.mkEnableOption (lib.mdDoc "Twingate Client daemon");
|
|
|
|
package = lib.mkPackageOptionMD pkgs "twingate" { };
|
2022-11-04 12:36:45 +00:00
|
|
|
};
|
|
|
|
|
2023-07-07 16:50:29 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
systemd.packages = [ cfg.package ];
|
|
|
|
systemd.services.twingate = {
|
|
|
|
preStart = "cp -r -n ${cfg.package}/etc/twingate/. /etc/twingate/";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
2022-11-04 12:36:45 +00:00
|
|
|
|
2023-07-07 16:50:29 +00:00
|
|
|
networking.firewall.checkReversePath = lib.mkDefault "loose";
|
|
|
|
services.resolved.enable = !(config.networking.networkmanager.enable);
|
2022-11-04 12:36:45 +00:00
|
|
|
|
2023-07-07 16:50:29 +00:00
|
|
|
environment.systemPackages = [ cfg.package ]; # For the CLI.
|
2022-11-04 12:36:45 +00:00
|
|
|
};
|
|
|
|
}
|