depot/third_party/nixpkgs/pkgs/tools/networking/v2raya/default.nix
Default email 5557ff764c Project import generated by Copybara.
GitOrigin-RevId: 988cc958c57ce4350ec248d2d53087777f9e1949
2023-02-22 11:55:15 +01:00

82 lines
2 KiB
Nix

{ lib
, fetchFromGitHub
, mkYarnPackage
, buildGoModule
, makeWrapper
, v2ray
, v2ray-geoip
, v2ray-domain-list-community
, symlinkJoin
}:
let
pname = "v2raya";
version = "2.0.0";
src = fetchFromGitHub {
owner = "v2rayA";
repo = "v2rayA";
rev = "v${version}";
sha256 = "sha256-1fWcrMd+TSrlS1H0z7XwVCQzZAa8DAFtlekEZNRMAPA=";
};
web = mkYarnPackage {
inherit pname version;
src = "${src}/gui";
yarnNix = ./yarn.nix;
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
buildPhase = ''
export NODE_OPTIONS=--openssl-legacy-provider
ln -s $src/postcss.config.js postcss.config.js
OUTPUT_DIR=$out yarn --offline build
'';
distPhase = "true";
dontInstall = true;
dontFixup = true;
};
assetsDir = symlinkJoin {
name = "assets";
paths = [ v2ray-geoip v2ray-domain-list-community ];
};
in
buildGoModule {
inherit pname version;
src = "${src}/service";
vendorSha256 = "sha256-Ud4pwS0lz7zSTowg3gXNllfDyj8fu33H1L20szxPcOA=";
ldflags = [
"-s"
"-w"
"-X github.com/v2rayA/v2rayA/conf.Version=${version}"
];
subPackages = [ "." ];
nativeBuildInputs = [ makeWrapper ];
preBuild = ''
cp -a ${web} server/router/web
'';
postInstall = ''
install -Dm 444 ${src}/install/universal/v2raya.desktop -t $out/share/applications
install -Dm 444 ${src}/install/universal/v2raya.png -t $out/share/icons/hicolor/512x512/apps
substituteInPlace $out/share/applications/v2raya.desktop \
--replace 'Icon=/usr/share/icons/hicolor/512x512/apps/v2raya.png' 'Icon=v2raya'
wrapProgram $out/bin/v2rayA \
--prefix PATH ":" "${lib.makeBinPath [ v2ray ]}" \
--prefix XDG_DATA_DIRS ":" ${assetsDir}/share
'';
meta = with lib; {
description = "A Linux web GUI client of Project V which supports V2Ray, Xray, SS, SSR, Trojan and Pingtunnel";
homepage = "https://github.com/v2rayA/v2rayA";
mainProgram = "v2rayA";
license = licenses.agpl3Only;
platforms = platforms.linux;
maintainers = with maintainers; [ elliot ];
};
}