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

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

100 lines
2.3 KiB
Nix
Raw Normal View History

{ lib
, fetchFromGitHub
, mkYarnPackage
, buildGoModule
, makeWrapper
, v2ray
, v2ray-geoip
, v2ray-domain-list-community
, symlinkJoin
2023-07-15 09:26:24 +00:00
, fetchYarnDeps
}:
let
pname = "v2raya";
2024-06-26 14:08:46 +00:00
version = "2.2.5.6";
2023-02-03 02:21:56 +00:00
src = fetchFromGitHub {
owner = "v2rayA";
repo = "v2rayA";
rev = "v${version}";
2024-06-26 14:08:46 +00:00
hash = "sha256-tXVyroQ2yXwLe+OulvVQYgfd9EcC87S0L8d7w5gLnMI=";
2023-07-15 09:26:24 +00:00
postFetch = "sed -i -e 's/npmmirror/yarnpkg/g' $out/gui/yarn.lock";
};
2023-07-15 09:26:24 +00:00
guiSrc = "${src}/gui";
2023-02-03 02:21:56 +00:00
web = mkYarnPackage {
inherit pname version;
2023-07-15 09:26:24 +00:00
src = guiSrc;
packageJSON = ./package.json;
2023-07-15 09:26:24 +00:00
offlineCache = fetchYarnDeps {
yarnLock = "${guiSrc}/yarn.lock";
2024-02-22 16:15:02 +00:00
sha256 = "sha256-AZIYkW2u1l9IaDpR9xiKNpc0sGAarLKwHf5kGnzdpKw=";
2023-07-15 09:26:24 +00:00
};
buildPhase = ''
runHook preBuild
OUTPUT_DIR=$out yarn --offline build
runHook postBuild
'';
2023-07-15 09:26:24 +00:00
configurePhase = ''
runHook preConfigure
2023-07-15 09:26:24 +00:00
cp -r $node_modules node_modules
chmod +w node_modules
runHook postConfigure
2023-07-15 09:26:24 +00:00
'';
distPhase = "true";
2023-07-15 09:26:24 +00:00
dontInstall = true;
dontFixup = true;
};
2023-02-03 02:21:56 +00:00
assetsDir = symlinkJoin {
name = "assets";
paths = [ v2ray-geoip v2ray-domain-list-community ];
};
in
buildGoModule {
inherit pname version;
2023-02-03 02:21:56 +00:00
src = "${src}/service";
2024-06-26 14:08:46 +00:00
vendorHash = "sha256-8MSNTKeN0N2/yaHnXsKmxzw9vRy+E5q60IpwLycqC2I=";
2023-02-03 02:21:56 +00:00
ldflags = [
"-s"
"-w"
"-X github.com/v2rayA/v2rayA/conf.Version=${version}"
];
2023-02-03 02:21:56 +00:00
subPackages = [ "." ];
2023-02-03 02:21:56 +00:00
nativeBuildInputs = [ makeWrapper ];
preBuild = ''
cp -a ${web} server/router/web
'';
2023-02-03 02:21:56 +00:00
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 ]}" \
2023-02-03 02:21:56 +00:00
--prefix XDG_DATA_DIRS ":" ${assetsDir}/share
'';
2023-02-03 02:21:56 +00:00
meta = with lib; {
description = "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; [ ChaosAttractor ];
};
}