nixpkgs/pkgs/tools/networking/v2ray/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.7 KiB
Nix
Raw Normal View History

2022-09-21 09:29:54 +03:00
{ lib, fetchFromGitHub, symlinkJoin, buildGoModule, makeWrapper, nixosTests
, nix-update-script
, v2ray-geoip, v2ray-domain-list-community
, assets ? [ v2ray-geoip v2ray-domain-list-community ]
2020-09-07 22:23:12 +03:00
}:
2019-10-02 22:05:07 +03:00
2022-09-21 09:29:54 +03:00
buildGoModule rec {
pname = "v2ray-core";
2024-03-19 20:26:47 +03:00
version = "5.15.1";
2019-10-02 22:05:07 +03:00
src = fetchFromGitHub {
2020-11-09 20:08:43 +03:00
owner = "v2fly";
2019-10-02 22:05:07 +03:00
repo = "v2ray-core";
rev = "v${version}";
2024-03-19 20:26:47 +03:00
hash = "sha256-EENeJQfIKHtbh5dmWeUtnVepIGsBsXMs6Yhi/QzeRRs=";
2019-10-02 22:05:07 +03:00
};
2022-09-21 09:29:54 +03:00
# `nix-update` doesn't support `vendorHash` yet.
# https://github.com/Mic92/nix-update/pull/95
2024-03-16 10:41:21 +03:00
vendorHash = "sha256-SQ7DcrKYf4Wclp/HG8e7q5YPvVNj/kHV/pGmEyOU/BY=";
ldflags = [ "-s" "-w" ];
2020-09-07 22:23:12 +03:00
2022-09-21 09:29:54 +03:00
subPackages = [ "main" ];
2020-09-07 22:23:12 +03:00
2022-09-21 09:29:54 +03:00
nativeBuildInputs = [ makeWrapper ];
2020-09-07 22:23:12 +03:00
2022-09-21 09:29:54 +03:00
installPhase = ''
runHook preInstall
install -Dm555 "$GOPATH"/bin/main $out/bin/v2ray
install -Dm444 release/config/systemd/system/v2ray{,@}.service -t $out/lib/systemd/system
install -Dm444 release/config/*.json -t $out/etc/v2ray
runHook postInstall
'';
2020-11-09 20:08:43 +03:00
2022-09-21 09:29:54 +03:00
assetsDrv = symlinkJoin {
name = "v2ray-assets";
paths = assets;
2020-09-07 22:23:12 +03:00
};
2022-09-21 09:29:54 +03:00
postFixup = ''
wrapProgram $out/bin/v2ray \
--suffix XDG_DATA_DIRS : $assetsDrv/share
substituteInPlace $out/lib/systemd/system/*.service \
--replace User=nobody DynamicUser=yes \
--replace /usr/local/bin/ $out/bin/ \
--replace /usr/local/etc/ /etc/
'';
2020-09-07 22:23:12 +03:00
passthru = {
updateScript = nix-update-script { };
2022-09-21 09:29:54 +03:00
tests.simple-vmess-proxy-test = nixosTests.v2ray;
2020-09-07 22:23:12 +03:00
};
2022-09-21 09:29:54 +03:00
meta = {
homepage = "https://www.v2fly.org/en_US/";
description = "A platform for building proxies to bypass network restrictions";
mainProgram = "v2ray";
2022-09-21 09:29:54 +03:00
license = with lib.licenses; [ mit ];
maintainers = with lib.maintainers; [ servalcatty ];
};
}