Refractor to dendritic approach.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
{...}: {
|
||||
config.flake.modules.homeManager.snx-rs = {
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.azos.snx-rs;
|
||||
in {
|
||||
options.azos.snx-rs = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
server = lib.mkOption {
|
||||
default = "vpn.bgu.ac.il";
|
||||
type = lib.types.str;
|
||||
description = "VPN server address";
|
||||
};
|
||||
username = lib.mkOption {
|
||||
default = "anerz@vpn";
|
||||
type = lib.types.str;
|
||||
description = "VPN username";
|
||||
};
|
||||
loginType = lib.mkOption {
|
||||
default = "vpn";
|
||||
type = lib.types.str;
|
||||
description = "Login type";
|
||||
};
|
||||
ignoreServerCert = lib.mkOption {
|
||||
default = true;
|
||||
type = lib.types.bool;
|
||||
description = "Ignore server certificate validation";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = with pkgs; [
|
||||
snx-rs
|
||||
(pkgs.writeShellScriptBin "snx-connect" ''
|
||||
#!/bin/sh
|
||||
sudo ${pkgs.snx-rs}/bin/snx-rs -m command &
|
||||
sleep 1
|
||||
${pkgs.snx-rs}/bin/snxctl connect
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "snx-disconnect" ''
|
||||
#!/bin/sh
|
||||
${pkgs.snx-rs}/bin/snxctl disconnect
|
||||
pkill -x snx-rs 2>/dev/null || true
|
||||
'')
|
||||
];
|
||||
home.file.".config/snx-rs/snx-rs.conf" = {
|
||||
text = ''
|
||||
server ${cfg.server}
|
||||
username ${cfg.username}
|
||||
login-type ${cfg.loginType}
|
||||
ignore-server-cert ${lib.boolToString cfg.ignoreServerCert}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user