nixos/{test/,}v2ray: fix for new CLI and use upstream systemd units

oxalica 07a9b7b1 4f962f65

Changed files
+20 -10
nixos
modules
services
networking
tests
+10 -8
nixos/modules/services/networking/v2ray.nix
···
Either `configFile` or `config` must be specified.
-
See <https://www.v2fly.org/en_US/config/overview.html>.
+
See <https://www.v2fly.org/en_US/v5/config/overview.html>.
'';
};
···
Either `configFile` or `config` must be specified.
-
See <https://www.v2fly.org/en_US/config/overview.html>.
+
See <https://www.v2fly.org/en_US/v5/config/overview.html>.
'';
};
};
···
name = "v2ray.json";
text = builtins.toJSON cfg.config;
checkPhase = ''
-
${cfg.package}/bin/v2ray -test -config $out
+
${cfg.package}/bin/v2ray test -c $out
'';
};
···
}
];
+
environment.etc."v2ray/config.json".source = configFile;
+
+
systemd.packages = [ cfg.package ];
+
systemd.services.v2ray = {
-
description = "v2ray Daemon";
-
after = [ "network.target" ];
+
restartTriggers = [ config.environment.etc."v2ray/config.json".source ];
+
+
# Workaround: https://github.com/NixOS/nixpkgs/issues/81138
wantedBy = [ "multi-user.target" ];
-
serviceConfig = {
-
ExecStart = "${cfg.package}/bin/v2ray -config ${configFile}";
-
};
};
};
}
+10 -2
nixos/tests/v2ray.nix
···
port = 1081;
listen = "127.0.0.1";
protocol = "vmess";
-
settings.clients = [v2rayUser];
+
settings.clients = [ v2rayUser ];
}
];
outbounds = [
···
settings.vnext = [{
address = "127.0.0.1";
port = 1081;
-
users = [v2rayUser];
+
users = [ v2rayUser ];
}];
}
{
···
{
type = "field";
inboundTag = "vmess_in";
+
outboundTag = "direct";
+
}
+
+
# Assert assets "geoip" and "geosite" are accessible.
+
{
+
type = "field";
+
ip = [ "geoip:private" ];
+
domain = [ "geosite:category-ads" ];
outboundTag = "direct";
}
];