2021-06-28 23:13:55 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.globalprotect;
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
execStart =
|
|
|
|
if cfg.csdWrapper == null then
|
2021-06-28 23:13:55 +00:00
|
|
|
"${pkgs.globalprotect-openconnect}/bin/gpservice"
|
|
|
|
else
|
|
|
|
"${pkgs.globalprotect-openconnect}/bin/gpservice --csd-wrapper=${cfg.csdWrapper}";
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options.services.globalprotect = {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption "globalprotect";
|
2021-06-28 23:13:55 +00:00
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
settings = mkOption {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-08-21 13:32:41 +00:00
|
|
|
GlobalProtect-openconnect configuration. For more information, visit
|
2022-09-09 14:08:57 +00:00
|
|
|
<https://github.com/yuezk/GlobalProtect-openconnect/wiki/Configuration>.
|
2022-08-21 13:32:41 +00:00
|
|
|
'';
|
|
|
|
default = { };
|
|
|
|
example = {
|
|
|
|
"vpn1.company.com" = {
|
|
|
|
openconnect-args = "--script=/path/to/vpnc-script";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
type = types.attrs;
|
|
|
|
};
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
csdWrapper = mkOption {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2021-06-28 23:13:55 +00:00
|
|
|
A script that will produce a Host Integrity Protection (HIP) report,
|
2022-08-12 12:06:08 +00:00
|
|
|
as described at <https://www.infradead.org/openconnect/hip.html>
|
2021-06-28 23:13:55 +00:00
|
|
|
'';
|
|
|
|
default = null;
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''"''${pkgs.openconnect}/libexec/openconnect/hipreport.sh"'';
|
2021-06-28 23:13:55 +00:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.dbus.packages = [ pkgs.globalprotect-openconnect ];
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
environment.etc."gpservice/gp.conf".text = lib.generators.toINI { } cfg.settings;
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
systemd.services.gpservice = {
|
|
|
|
description = "GlobalProtect openconnect DBus service";
|
|
|
|
serviceConfig = {
|
2022-08-21 13:32:41 +00:00
|
|
|
Type = "dbus";
|
|
|
|
BusName = "com.yuezk.qt.GPService";
|
|
|
|
ExecStart = execStart;
|
2021-06-28 23:13:55 +00:00
|
|
|
};
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|