services.xray: fix

This commit is contained in:
2024-06-04 01:05:29 +08:00
parent 37d90d0ed2
commit f31dcbc640
8 changed files with 28 additions and 30 deletions

View File

@@ -53,7 +53,7 @@ inputs:
snapper.enable = true;
samba = { enable = true; hostsAllowed = "192.168. 127."; shares = { home.path = "/home"; root.path = "/"; }; };
sshd = {};
xray.client.dnsmasq.hosts."git.nas.chn.moe" = "127.0.0.1";
xray.client = { enable = true; dnsmasq.hosts."git.nas.chn.moe" = "127.0.0.1"; };
groupshare = {};
smartd.enable = true;
beesd.instances =

View File

@@ -88,6 +88,7 @@ inputs:
sshd = {};
xray.client =
{
enable = true;
dnsmasq.hosts = builtins.listToAttrs
(
(builtins.map

View File

@@ -26,7 +26,7 @@ inputs:
{
# snapper.enable = true;
sshd = {};
xray.client = {};
xray.client.enable = true;
fail2ban = {};
wireguard =
{

View File

@@ -42,7 +42,7 @@ inputs:
{
snapper.enable = true;
sshd = {};
xray.client = {};
xray.client.enable = true;
firewall.trustedInterfaces = [ "virbr0" ];
wireguard =
{

View File

@@ -58,7 +58,7 @@ inputs:
{
snapper.enable = true;
sshd = { passwordAuthentication = true; groupBanner = true; };
xray.client = {};
xray.client.enable = true;
firewall.trustedInterfaces = [ "virbr0" "waydroid0" ];
smartd.enable = true;
beesd.instances =

View File

@@ -52,7 +52,7 @@ inputs:
{
snapper.enable = true;
sshd = { passwordAuthentication = true; groupBanner = true; };
xray.client = {};
xray.client.enable = true;
firewall.trustedInterfaces = [ "virbr0" "waydroid0" ];
smartd.enable = true;
beesd.instances.root = { device = "/"; hashTableSizeMB = 16384; threads = 4; };

View File

@@ -9,7 +9,7 @@ inputs:
behindNat = mkOption
{
type = types.bool;
default = inputs.config.nixos.services.xray.client != null;
default = inputs.config.nixos.services.xray.client.enable;
};
listenIp = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
# if the host is behind xray, it should listen on another port, to make xray succeffully listen on 51820

View File

@@ -2,32 +2,29 @@ inputs:
{
options.nixos.services.xray = let inherit (inputs.lib) mkOption types; in
{
client = mkOption
client =
{
type = types.nullOr (types.submodule { options =
enable = mkOption { type = types.bool; default = false; };
xray =
{
xray =
serverAddress = mkOption { type = types.nonEmptyStr; default = "74.211.99.69"; };
serverName = mkOption { type = types.nonEmptyStr; default = "vps6.xserver.chn.moe"; };
};
dnsmasq =
{
extraInterfaces = mkOption
{
serverAddress = mkOption { type = types.nonEmptyStr; default = "74.211.99.69"; };
serverName = mkOption { type = types.nonEmptyStr; default = "vps6.xserver.chn.moe"; };
type = types.listOf types.nonEmptyStr;
default = inputs.lib.optional inputs.config.nixos.virtualization.docker.enable "docker0";
};
dnsmasq =
{
extraInterfaces = mkOption
{
type = types.listOf types.nonEmptyStr;
default = inputs.lib.optional inputs.config.nixos.virtualization.docker.enable "docker0";
};
hosts = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; };
};
v2ray-forwarder =
{
noproxyUsers = mkOption { type = types.listOf types.nonEmptyStr; default = [ "gb" "xll" ]; };
noproxyTcpPorts = mkOption { type = types.listOf types.ints.unsigned; default = []; };
noproxyUdpPorts = mkOption { type = types.listOf types.ints.unsigned; default = []; };
};
};});
default = null;
hosts = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; };
};
v2ray-forwarder =
{
noproxyUsers = mkOption { type = types.listOf types.nonEmptyStr; default = [ "gb" "xll" ]; };
noproxyTcpPorts = mkOption { type = types.listOf types.ints.unsigned; default = []; };
noproxyUdpPorts = mkOption { type = types.listOf types.ints.unsigned; default = []; };
};
};
server = mkOption
{
@@ -44,12 +41,12 @@ inputs:
{
assertions =
[{
assertion = !(xray.client != null && xray.server != null);
assertion = !(xray.client.enable && xray.server != null);
message = "Currenty xray.client and xray.server could not be simutaniusly enabled.";
}];
}
(
inputs.lib.mkIf (xray.client != null)
inputs.lib.mkIf xray.client.enable
{
services =
{