nixpkgs/pkgs/by-name/v2/v2ray/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

63 lines
1.7 KiB
Nix

{ lib, fetchFromGitHub, symlinkJoin, buildGoModule, makeWrapper, nixosTests
, nix-update-script
, v2ray-geoip, v2ray-domain-list-community
, assets ? [ v2ray-geoip v2ray-domain-list-community ]
}:
buildGoModule rec {
pname = "v2ray-core";
version = "5.20.0";
src = fetchFromGitHub {
owner = "v2fly";
repo = "v2ray-core";
rev = "v${version}";
hash = "sha256-9YPFgsU1XpdT+fRaJmEB3z5sKjkrG3aiRIV3r4cDLfE=";
};
# `nix-update` doesn't support `vendorHash` yet.
# https://github.com/Mic92/nix-update/pull/95
vendorHash = "sha256-Z+jM02SzmpuZ3PXXqrLDIOWDhIh8AxMUr1S4A+du5LU=";
ldflags = [ "-s" "-w" ];
subPackages = [ "main" ];
nativeBuildInputs = [ makeWrapper ];
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
'';
assetsDrv = symlinkJoin {
name = "v2ray-assets";
paths = assets;
};
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/
'';
passthru = {
updateScript = nix-update-script { };
tests.simple-vmess-proxy-test = nixosTests.v2ray;
};
meta = {
homepage = "https://www.v2fly.org/en_US/";
description = "Platform for building proxies to bypass network restrictions";
mainProgram = "v2ray";
license = with lib.licenses; [ mit ];
maintainers = with lib.maintainers; [ servalcatty ];
};
}