Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a0943687d2a5094a6d92f25a4b6e16a76b5b7
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

73 lines
1.9 KiB
Nix

{
config,
pkgs,
lib,
...
}:
with lib;
let
cfg = config.services.v2raya;
in
{
options = {
services.v2raya = {
enable = options.mkEnableOption "the v2rayA service";
package = options.mkPackageOption pkgs "v2raya" { };
cliPackage = options.mkPackageOption pkgs "v2ray" {
example = "pkgs.xray";
extraDescription = "This is the package used for overriding the value of the `v2ray` attribute in the package set by `services.v2raya.package`.";
};
};
};
config = mkIf config.services.v2raya.enable {
environment.systemPackages = [ (cfg.package.override { v2ray = cfg.cliPackage; }) ];
systemd.services.v2raya =
let
nftablesEnabled = config.networking.nftables.enable;
iptablesServices = [
"iptables.service"
] ++ optional config.networking.enableIPv6 "ip6tables.service";
tableServices = if nftablesEnabled then [ "nftables.service" ] else iptablesServices;
in
{
unitConfig = {
Description = "v2rayA service";
Documentation = "https://github.com/v2rayA/v2rayA/wiki";
After = [
"network.target"
"nss-lookup.target"
] ++ tableServices;
Wants = [ "network.target" ];
};
serviceConfig = {
User = "root";
ExecStart = "${getExe (cfg.package.override { v2ray = cfg.cliPackage; })} --log-disable-timestamp";
Environment = [ "V2RAYA_LOG_FILE=/var/log/v2raya/v2raya.log" ];
LimitNPROC = 500;
LimitNOFILE = 1000000;
Restart = "on-failure";
Type = "simple";
};
wantedBy = [ "multi-user.target" ];
path =
with pkgs;
[
iptables
bash
iproute2
]
++ lib.optionals nftablesEnabled [ nftables ]; # required by v2rayA TProxy functionality
};
};
meta.maintainers = with maintainers; [ elliot ];
}