lol

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

oxalica 07a9b7b1 4f962f65

+20 -10
+10 -8
nixos/modules/services/networking/v2ray.nix
··· 34 34 35 35 Either `configFile` or `config` must be specified. 36 36 37 - See <https://www.v2fly.org/en_US/config/overview.html>. 37 + See <https://www.v2fly.org/en_US/v5/config/overview.html>. 38 38 ''; 39 39 }; 40 40 ··· 56 56 57 57 Either `configFile` or `config` must be specified. 58 58 59 - See <https://www.v2fly.org/en_US/config/overview.html>. 59 + See <https://www.v2fly.org/en_US/v5/config/overview.html>. 60 60 ''; 61 61 }; 62 62 }; ··· 71 71 name = "v2ray.json"; 72 72 text = builtins.toJSON cfg.config; 73 73 checkPhase = '' 74 - ${cfg.package}/bin/v2ray -test -config $out 74 + ${cfg.package}/bin/v2ray test -c $out 75 75 ''; 76 76 }; 77 77 ··· 83 83 } 84 84 ]; 85 85 86 + environment.etc."v2ray/config.json".source = configFile; 87 + 88 + systemd.packages = [ cfg.package ]; 89 + 86 90 systemd.services.v2ray = { 87 - description = "v2ray Daemon"; 88 - after = [ "network.target" ]; 91 + restartTriggers = [ config.environment.etc."v2ray/config.json".source ]; 92 + 93 + # Workaround: https://github.com/NixOS/nixpkgs/issues/81138 89 94 wantedBy = [ "multi-user.target" ]; 90 - serviceConfig = { 91 - ExecStart = "${cfg.package}/bin/v2ray -config ${configFile}"; 92 - }; 93 95 }; 94 96 }; 95 97 }
+10 -2
nixos/tests/v2ray.nix
··· 20 20 port = 1081; 21 21 listen = "127.0.0.1"; 22 22 protocol = "vmess"; 23 - settings.clients = [v2rayUser]; 23 + settings.clients = [ v2rayUser ]; 24 24 } 25 25 ]; 26 26 outbounds = [ ··· 30 30 settings.vnext = [{ 31 31 address = "127.0.0.1"; 32 32 port = 1081; 33 - users = [v2rayUser]; 33 + users = [ v2rayUser ]; 34 34 }]; 35 35 } 36 36 { ··· 47 47 { 48 48 type = "field"; 49 49 inboundTag = "vmess_in"; 50 + outboundTag = "direct"; 51 + } 52 + 53 + # Assert assets "geoip" and "geosite" are accessible. 54 + { 55 + type = "field"; 56 + ip = [ "geoip:private" ]; 57 + domain = [ "geosite:category-ads" ]; 50 58 outboundTag = "direct"; 51 59 } 52 60 ];