normcap: fix on GNOME wayland when used via keybind or alt-f2 (#351763)
[NixPkgs.git] / nixos / modules / services / networking / v2raya.nix
bloba1b574870218c60e9705a665fff6dc651e150efa
2   config,
3   pkgs,
4   lib,
5   ...
6 }:
8 with lib;
10 let
11   cfg = config.services.v2raya;
15   options = {
16     services.v2raya = {
17       enable = options.mkEnableOption "the v2rayA service";
19       package = options.mkPackageOption pkgs "v2raya" { };
20       cliPackage = options.mkPackageOption pkgs "v2ray" {
21         example = "pkgs.xray";
22         extraDescription = "This is the package used for overriding the value of the `v2ray` attribute in the package set by `services.v2raya.package`.";
23       };
24     };
25   };
27   config = mkIf config.services.v2raya.enable {
28     environment.systemPackages = [ (cfg.package.override { v2ray = cfg.cliPackage; }) ];
30     systemd.services.v2raya =
31       let
32         nftablesEnabled = config.networking.nftables.enable;
33         iptablesServices = [
34           "iptables.service"
35         ] ++ optional config.networking.enableIPv6 "ip6tables.service";
36         tableServices = if nftablesEnabled then [ "nftables.service" ] else iptablesServices;
37       in
38       {
39         unitConfig = {
40           Description = "v2rayA service";
41           Documentation = "https://github.com/v2rayA/v2rayA/wiki";
42           After = [
43             "network.target"
44             "nss-lookup.target"
45           ] ++ tableServices;
46           Wants = [ "network.target" ];
47         };
49         serviceConfig = {
50           User = "root";
51           ExecStart = "${getExe (cfg.package.override { v2ray = cfg.cliPackage; })} --log-disable-timestamp";
52           Environment = [ "V2RAYA_LOG_FILE=/var/log/v2raya/v2raya.log" ];
53           LimitNPROC = 500;
54           LimitNOFILE = 1000000;
55           Restart = "on-failure";
56           Type = "simple";
57         };
59         wantedBy = [ "multi-user.target" ];
60         path =
61           with pkgs;
62           [
63             iptables
64             bash
65             iproute2
66           ]
67           ++ lib.optionals nftablesEnabled [ nftables ]; # required by v2rayA TProxy functionality
68       };
69   };
71   meta.maintainers = with maintainers; [ elliot ];