2023-03-27 08:18:13 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
options.programs.clash-verge = {
|
2023-09-11 08:17:54 +02:00
|
|
|
enable = lib.mkEnableOption "Clash Verge";
|
2024-03-10 20:03:25 +01:00
|
|
|
package = lib.mkPackageOption pkgs "clash-verge" {};
|
2023-09-11 08:17:54 +02:00
|
|
|
autoStart = lib.mkEnableOption "Clash Verge auto launch";
|
|
|
|
tunMode = lib.mkEnableOption "Clash Verge TUN mode";
|
2023-03-27 08:18:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
cfg = config.programs.clash-verge;
|
|
|
|
in
|
|
|
|
lib.mkIf cfg.enable {
|
|
|
|
|
|
|
|
environment.systemPackages = [
|
2024-03-10 20:03:25 +01:00
|
|
|
cfg.package
|
2023-03-27 08:18:13 +02:00
|
|
|
(lib.mkIf cfg.autoStart (pkgs.makeAutostartItem {
|
|
|
|
name = "clash-verge";
|
2024-03-10 20:03:25 +01:00
|
|
|
package = cfg.package;
|
2023-03-27 08:18:13 +02:00
|
|
|
}))
|
|
|
|
];
|
|
|
|
|
|
|
|
security.wrappers.clash-verge = lib.mkIf cfg.tunMode {
|
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
|
|
|
capabilities = "cap_net_bind_service,cap_net_admin=+ep";
|
2024-03-10 20:03:25 +01:00
|
|
|
source = "${lib.getExe cfg.package}";
|
2023-03-27 08:18:13 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ zendo ];
|
|
|
|
}
|