summary refs log tree commit diff
path: root/nixos/modules/services/networking/v2ray.nix
diff options
context:
space:
mode:
authorPoscat <poscat@mail.poscat.moe>2021-08-13 11:18:24 +0800
committerPoscat <poscat@mail.poscat.moe>2021-10-08 12:02:10 +0800
commite4dd32f67e57dfff417678f9a6e018450bdee1c1 (patch)
treeca7c60e973285c6c1eae08e6aaa90a6ddbe18caf /nixos/modules/services/networking/v2ray.nix
parent439b1605227b8adb1357b55ce8529d541abbe9eb (diff)
downloadnixpkgs-e4dd32f67e57dfff417678f9a6e018450bdee1c1.tar
nixpkgs-e4dd32f67e57dfff417678f9a6e018450bdee1c1.tar.gz
nixpkgs-e4dd32f67e57dfff417678f9a6e018450bdee1c1.tar.bz2
nixpkgs-e4dd32f67e57dfff417678f9a6e018450bdee1c1.tar.lz
nixpkgs-e4dd32f67e57dfff417678f9a6e018450bdee1c1.tar.xz
nixpkgs-e4dd32f67e57dfff417678f9a6e018450bdee1c1.tar.zst
nixpkgs-e4dd32f67e57dfff417678f9a6e018450bdee1c1.zip
nixos/v2ray: add an option for specifying v2ray package used in the systemd service
Diffstat (limited to 'nixos/modules/services/networking/v2ray.nix')
-rw-r--r--nixos/modules/services/networking/v2ray.nix18
1 files changed, 13 insertions, 5 deletions
diff --git a/nixos/modules/services/networking/v2ray.nix b/nixos/modules/services/networking/v2ray.nix
index 6a924a16449..7b14082ee81 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}";
+      };
     };
   };
 }