about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/networking/twingate.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/networking/twingate.nix')
-rw-r--r--nixpkgs/nixos/modules/services/networking/twingate.nix24
1 files changed, 24 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/services/networking/twingate.nix b/nixpkgs/nixos/modules/services/networking/twingate.nix
new file mode 100644
index 000000000000..6874b1c18b57
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/networking/twingate.nix
@@ -0,0 +1,24 @@
+{ config, lib, pkgs, ... }:
+
+let
+  cfg = config.services.twingate;
+in
+{
+  options.services.twingate = {
+    enable = lib.mkEnableOption (lib.mdDoc "Twingate Client daemon");
+    package = lib.mkPackageOption pkgs "twingate" { };
+  };
+
+  config = lib.mkIf cfg.enable {
+    systemd.packages = [ cfg.package ];
+    systemd.services.twingate = {
+      preStart = "cp -r --update=none ${cfg.package}/etc/twingate/. /etc/twingate/";
+      wantedBy = [ "multi-user.target" ];
+    };
+
+    networking.firewall.checkReversePath = lib.mkDefault "loose";
+    services.resolved.enable = lib.mkIf (!config.networking.networkmanager.enable) true;
+
+    environment.systemPackages = [ cfg.package ]; # For the CLI.
+  };
+}