diff --git a/nixos/modules/services/networking/v2ray.nix b/nixos/modules/services/networking/v2ray.nix index 0b8b5b56e25b..95e8761ba5cc 100644 --- a/nixos/modules/services/networking/v2ray.nix +++ b/nixos/modules/services/networking/v2ray.nix @@ -16,6 +16,15 @@ with lib; ''; }; + package = mkOption { + type = types.package; + default = pkgs.v2ray; + defaultText = literalExpression "pkgs.v2ray"; + description = '' + Which v2ray package to use. + ''; + }; + configFile = mkOption { type = types.nullOr types.str; default = null; @@ -62,7 +71,7 @@ with lib; name = "v2ray.json"; text = builtins.toJSON cfg.config; checkPhase = '' - ${pkgs.v2ray}/bin/v2ray -test -config $out + ${cfg.package}/bin/v2ray -test -config $out ''; }; @@ -78,10 +87,9 @@ with lib; description = "v2ray Daemon"; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; - path = [ pkgs.v2ray ]; - script = '' - exec v2ray -config ${configFile} - ''; + serviceConfig = { + ExecStart = "${cfg.package}/bin/v2ray -config ${configFile}"; + }; }; }; }