vuls: init at 0.27.0
[NixPkgs.git] / nixos / modules / services / networking / v2raya.nix
blobaefb47bf048dbd5eaaa0c1e8078d79d4a4ed0f84
1 { config, pkgs, lib, ... }:
3 with lib;
6   options = {
7     services.v2raya = {
8       enable = options.mkEnableOption "the v2rayA service";
9     };
10   };
12   config = mkIf config.services.v2raya.enable {
13     environment.systemPackages = [ pkgs.v2raya ];
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         };
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         };
44         wantedBy = [ "multi-user.target" ];
45         path = with pkgs; [ iptables bash iproute2 ] ++ lib.optionals nftablesEnabled [ nftables ]; # required by v2rayA TProxy functionality
46       };
47   };
49   meta.maintainers = with maintainers; [ elliot ];