2023-04-29 16:46:19 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
options.programs.clash-verge = {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = lib.mkEnableOption "Clash Verge";
|
|
|
|
package = lib.mkPackageOption pkgs "clash-verge" {};
|
|
|
|
autoStart = lib.mkEnableOption "Clash Verge auto launch";
|
|
|
|
tunMode = lib.mkEnableOption "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 = [
|
2024-04-21 15:54:59 +00:00
|
|
|
cfg.package
|
2023-04-29 16:46:19 +00:00
|
|
|
(lib.mkIf cfg.autoStart (pkgs.makeAutostartItem {
|
|
|
|
name = "clash-verge";
|
2024-04-21 15:54:59 +00:00
|
|
|
package = cfg.package;
|
2023-04-29 16:46:19 +00:00
|
|
|
}))
|
|
|
|
];
|
|
|
|
|
|
|
|
security.wrappers.clash-verge = lib.mkIf cfg.tunMode {
|
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
|
|
|
capabilities = "cap_net_bind_service,cap_net_admin=+ep";
|
2024-04-21 15:54:59 +00:00
|
|
|
source = "${lib.getExe cfg.package}";
|
2023-04-29 16:46:19 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ zendo ];
|
|
|
|
}
|