Merge pull request #133700 from poscat0x04/v2ray-add-package-option

nixos/v2ray: add an option for specifying v2ray package used in the systemd service
This commit is contained in:
Bobby Rong 2021-10-08 12:38:15 +08:00 committed by GitHub
commit 6a1c868a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 { configFile = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
@ -62,7 +71,7 @@ with lib;
name = "v2ray.json"; name = "v2ray.json";
text = builtins.toJSON cfg.config; text = builtins.toJSON cfg.config;
checkPhase = '' checkPhase = ''
${pkgs.v2ray}/bin/v2ray -test -config $out ${cfg.package}/bin/v2ray -test -config $out
''; '';
}; };
@ -78,10 +87,9 @@ with lib;
description = "v2ray Daemon"; description = "v2ray Daemon";
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
path = [ pkgs.v2ray ]; serviceConfig = {
script = '' ExecStart = "${cfg.package}/bin/v2ray -config ${configFile}";
exec v2ray -config ${configFile} };
'';
}; };
}; };
} }