1{ config, pkgs, lib, ... }:
2
3with lib;
4
5{
6 options = {
7 services.v2raya = {
8 enable = options.mkEnableOption (mdDoc "the v2rayA service");
9 };
10 };
11
12 config = mkIf config.services.v2raya.enable {
13 environment.systemPackages = [ pkgs.v2raya ];
14
15 systemd.services.v2raya =
16 let
17 nftablesEnabled = config.networking.nftables.enable;
18 iptablesServices = [
19 "iptables.service"
20 ] ++ optional config.networking.enableIPv6 "ip6tables.service";
21 tableServices = if nftablesEnabled then [ "nftables.service" ] else iptablesServices;
22 in
23 {
24 unitConfig = {
25 Description = "v2rayA service";
26 Documentation = "https://github.com/v2rayA/v2rayA/wiki";
27 After = [
28 "network.target"
29 "nss-lookup.target"
30 ] ++ tableServices;
31 Wants = [ "network.target" ];
32 };
33
34 serviceConfig = {
35 User = "root";
36 ExecStart = "${getExe pkgs.v2raya} --log-disable-timestamp";
37 Environment = [ "V2RAYA_LOG_FILE=/var/log/v2raya/v2raya.log" ];
38 LimitNPROC = 500;
39 LimitNOFILE = 1000000;
40 Restart = "on-failure";
41 Type = "simple";
42 };
43
44 wantedBy = [ "multi-user.target" ];
45 path = with pkgs; [ iptables bash iproute2 ]; # required by v2rayA TProxy functionality
46 };
47 };
48
49 meta.maintainers = with maintainers; [ elliot ];
50}