1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 11:40:45 +00:00

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

This commit is contained in:
oxalica 2022-09-21 14:39:00 +08:00
parent 4f962f65c4
commit 07a9b7b1d8
2 changed files with 20 additions and 10 deletions

View file

@ -34,7 +34,7 @@ with lib;
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>.
'';
};
@ -56,7 +56,7 @@ with lib;
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>.
'';
};
};
@ -71,7 +71,7 @@ with lib;
name = "v2ray.json";
text = builtins.toJSON cfg.config;
checkPhase = ''
${cfg.package}/bin/v2ray -test -config $out
${cfg.package}/bin/v2ray test -c $out
'';
};
@ -83,13 +83,15 @@ with lib;
}
];
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}";
};
};
};
}

View file

@ -20,7 +20,7 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: let
port = 1081;
listen = "127.0.0.1";
protocol = "vmess";
settings.clients = [v2rayUser];
settings.clients = [ v2rayUser ];
}
];
outbounds = [
@ -30,7 +30,7 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: let
settings.vnext = [{
address = "127.0.0.1";
port = 1081;
users = [v2rayUser];
users = [ v2rayUser ];
}];
}
{
@ -49,6 +49,14 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: let
inboundTag = "vmess_in";
outboundTag = "direct";
}
# Assert assets "geoip" and "geosite" are accessible.
{
type = "field";
ip = [ "geoip:private" ];
domain = [ "geosite:category-ads" ];
outboundTag = "direct";
}
];
};