2023-04-29 16:46:19 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
options.programs.clash-verge = {
|
2023-10-09 19:29:22 +00:00
|
|
|
enable = lib.mkEnableOption (lib.mdDoc "Clash Verge");
|
|
|
|
autoStart = lib.mkEnableOption (lib.mdDoc "Clash Verge auto launch");
|
|
|
|
tunMode = lib.mkEnableOption (lib.mdDoc "Clash Verge TUN mode");
|
2023-04-29 16:46:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
cfg = config.programs.clash-verge;
|
|
|
|
in
|
|
|
|
lib.mkIf cfg.enable {
|
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
pkgs.clash-verge
|
|
|
|
(lib.mkIf cfg.autoStart (pkgs.makeAutostartItem {
|
|
|
|
name = "clash-verge";
|
|
|
|
package = pkgs.clash-verge;
|
|
|
|
}))
|
|
|
|
];
|
|
|
|
|
|
|
|
security.wrappers.clash-verge = lib.mkIf cfg.tunMode {
|
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
|
|
|
capabilities = "cap_net_bind_service,cap_net_admin=+ep";
|
|
|
|
source = "${lib.getExe pkgs.clash-verge}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ zendo ];
|
|
|
|
}
|