hiddify-app: refactor
This commit is contained in:
@@ -1,51 +1,50 @@
|
||||
{
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
pkg-config,
|
||||
flutter324,
|
||||
buildGoModule,
|
||||
libayatana-appindicator,
|
||||
makeDesktopItem,
|
||||
copyDesktopItems,
|
||||
wrapGAppsHook3,
|
||||
autoPatchelfHook,
|
||||
}:
|
||||
let
|
||||
pname = "hiddify-app";
|
||||
version = "2.5.7-unstable-2025-01-06";
|
||||
src = fetchFromGitHub {
|
||||
owner = "hiddify";
|
||||
repo = "hiddify-app";
|
||||
rev = "e5a1e1d6661039afcdef68406f978f3b6ef56412";
|
||||
hash = "sha256-OFT5sVFiE/8HytFis/s8FyM3lgKOAWj77zvhHkMaikk=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
libcore = buildGoModule rec {
|
||||
inherit pname version src;
|
||||
|
||||
modRoot = "./libcore";
|
||||
let
|
||||
metaCommon = {
|
||||
description = "Multi-platform auto-proxy client, supporting Sing-box, X-ray, TUIC, Hysteria, Reality, Trojan, SSH etc";
|
||||
license = with lib.licenses; [
|
||||
unfree # upstream adds non-free additional conditions. https://github.com/hiddify/hiddify-app/blob/0f6b15057f626016fcd7a0c075f1c8c2f606110a/LICENSE.md#additional-conditions-to-gpl-v3
|
||||
gpl3Only
|
||||
];
|
||||
maintainers = with lib.maintainers; [ ];
|
||||
};
|
||||
|
||||
libcore = buildGoModule rec {
|
||||
pname = "hiddify-core";
|
||||
version = "3.1.8";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "hiddify";
|
||||
repo = "hiddify-core";
|
||||
tag = "v${version}";
|
||||
hash = "sha256-NRzzkC3xbRVP20Pm29bHf8YpxmnjISgF46c8l9qU4rA=";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-a7NFZt4/w2+oaZG3ncaOrrhASxUptcWS/TeaIQrgLe4=";
|
||||
|
||||
GO_PUBLIC_FLAGS = ''
|
||||
GO_BUILD_FLAGS = ''
|
||||
-tags "with_gvisor,with_quic,with_wireguard,with_ech,with_utls,with_clash_api,with_grpc" \
|
||||
-trimpath \
|
||||
-ldflags "-s -w" \
|
||||
'';
|
||||
|
||||
postPatch = ''
|
||||
sed -i '/import (/a\ \t"os"\n\t"path/filepath"' ./libcore/v2/db/hiddify_db.go
|
||||
substituteInPlace ./libcore/v2/db/hiddify_db.go \
|
||||
--replace-fail 'NewGoLevelDBWithOpts(name, "./data", ' 'NewGoLevelDBWithOpts(name, filepath.Join(os.Getenv("HOME"), ".local", "share", "app.hiddify.com", "data"), '
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
go build ${GO_PUBLIC_FLAGS} -buildmode=c-shared -o bin/lib/libcore.so ./custom
|
||||
go build ${GO_BUILD_FLAGS} -buildmode=c-shared -o bin/lib/libcore.so ./custom
|
||||
mkdir lib
|
||||
cp bin/lib/libcore.so ./lib/libcore.so
|
||||
CGO_LDFLAGS="./lib/libcore.so" go build ${GO_PUBLIC_FLAGS} -o bin/HiddifyCli ./cli/bydll
|
||||
CGO_LDFLAGS="./lib/libcore.so" go build ${GO_BUILD_FLAGS} -o bin/HiddifyCli ./cli/bydll
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
@@ -53,56 +52,62 @@ let
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm0755 ./bin/HiddifyCli $out/bin/HiddifyCli
|
||||
install -Dm0755 ./lib/libcore.so $out/lib/libcore.so
|
||||
install -Dm0755 bin/HiddifyCli $out/bin/HiddifyCli
|
||||
install -Dm0755 lib/libcore.so $out/lib/libcore.so
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Multi-platform auto-proxy client, supporting Sing-box, X-ray, TUIC, Hysteria, Reality, Trojan, SSH etc";
|
||||
homepage = "https://hiddify.com";
|
||||
meta = metaCommon // {
|
||||
homepage = "https://github.com/hiddify/hiddify-core";
|
||||
mainProgram = "HiddifyCli";
|
||||
license = with lib.licenses; [
|
||||
unfree # upstream adds non-free additional conditions. https://github.com/hiddify/hiddify-core/blob/f993a57755c37e08b02042037cbbf508c66c51f9/LICENSE.md#summary
|
||||
gpl3Only
|
||||
];
|
||||
platforms = lib.platforms.linux;
|
||||
maintainers = with lib.maintainers; [ ];
|
||||
};
|
||||
};
|
||||
in
|
||||
flutter324.buildFlutterApplication {
|
||||
inherit pname version src;
|
||||
pname = "hiddify-app";
|
||||
version = "2.5.7-unstable-2025-01-06";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "hiddify";
|
||||
repo = "hiddify-app";
|
||||
rev = "a7547d298a5f8058446b6a470e56fe4efa3c1ccd";
|
||||
hash = "sha256-5I/k2KxdWiNsgwJY+bqMVqtC2eGshKbpLYzsPrmvhmY=";
|
||||
};
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
|
||||
gitHashes = {
|
||||
circle_flags = "sha256-dqORH4yj0jU8r9hP9NTjrlEO0ReHt4wds7BhgRPq57g=";
|
||||
flutter_easy_permission = "sha256-fs2dIwFLmeDrlFIIocGw6emOW1whGi9W7nQ7mHqp8R0=";
|
||||
humanizer = "sha256-zsDeol5l6maT8L8R6RRtHyd7CJn5908nvRXIytxiPqc=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace linux/my_application.cc \
|
||||
--replace-fail "./hiddify.png" "${placeholder "out"}/share/pixmaps/hiddify.png"
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoPatchelfHook
|
||||
copyDesktopItems
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
libayatana-appindicator
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
autoPatchelfHook
|
||||
wrapGAppsHook3
|
||||
copyDesktopItems
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace ./linux/my_application.cc \
|
||||
--replace-fail "./hiddify.png" "${placeholder "out"}/share/pixmaps/hiddify.png"
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
mkdir -p libcore/bin
|
||||
cp -r ${libcore}/lib libcore/bin/lib
|
||||
cp ${libcore}/bin/HiddifyCli libcore/bin/HiddifyCli
|
||||
packageRun build_runner build --delete-conflicting-outputs
|
||||
packageRun slang
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
install -Dm0644 ./assets/images/source/ic_launcher_border.png $out/share/pixmaps/hiddify.png
|
||||
'';
|
||||
flutterBuildFlags = [
|
||||
"--target lib/main_prod.dart"
|
||||
];
|
||||
|
||||
desktopItems = [
|
||||
(makeDesktopItem {
|
||||
@@ -127,33 +132,21 @@ flutter324.buildFlutterApplication {
|
||||
})
|
||||
];
|
||||
|
||||
flutterBuildFlags = [
|
||||
"--target lib/main_prod.dart"
|
||||
];
|
||||
|
||||
gitHashes = {
|
||||
circle_flags = "sha256-dqORH4yj0jU8r9hP9NTjrlEO0ReHt4wds7BhgRPq57g=";
|
||||
flutter_easy_permission = "sha256-fs2dIwFLmeDrlFIIocGw6emOW1whGi9W7nQ7mHqp8R0=";
|
||||
humanizer = "sha256-zsDeol5l6maT8L8R6RRtHyd7CJn5908nvRXIytxiPqc=";
|
||||
};
|
||||
|
||||
extraWrapProgramArgs = ''
|
||||
--prefix LD_LIBRARY_PATH : "$out/app/${pname}/lib"
|
||||
postInstall = ''
|
||||
install -Dm0644 assets/images/source/ic_launcher_border.png $out/share/pixmaps/hiddify.png
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" $out/app/${pname}/lib/lib*.so
|
||||
patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" $out/app/hiddify-app/lib/lib*.so
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Multi-platform auto-proxy client, supporting Sing-box, X-ray, TUIC, Hysteria, Reality, Trojan, SSH etc";
|
||||
extraWrapProgramArgs = ''
|
||||
--prefix LD_LIBRARY_PATH : $out/app/hiddify-app/lib
|
||||
'';
|
||||
|
||||
meta = metaCommon // {
|
||||
homepage = "https://hiddify.com";
|
||||
mainProgram = "hiddify";
|
||||
license = with lib.licenses; [
|
||||
unfree # upstream adds non-free additional conditions. https://github.com/hiddify/hiddify-app/blob/0f6b15057f626016fcd7a0c075f1c8c2f606110a/LICENSE.md#additional-conditions-to-gpl-v3
|
||||
gpl3Only
|
||||
];
|
||||
platforms = lib.platforms.linux;
|
||||
maintainers = with lib.maintainers; [ ];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user