From 3ed37b77a5917beac417f49f7e72ec55c9c96fb9 Mon Sep 17 00:00:00 2001 From: dr56ekgbb Date: Sun, 3 Nov 2024 02:28:47 +0800 Subject: [PATCH] gui-for-singbox: init at 1.8.9 --- pkgs/by-name/gu/gui-for-singbox/bridge.patch | 34 +++++ pkgs/by-name/gu/gui-for-singbox/package.nix | 133 +++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 pkgs/by-name/gu/gui-for-singbox/bridge.patch create mode 100644 pkgs/by-name/gu/gui-for-singbox/package.nix diff --git a/pkgs/by-name/gu/gui-for-singbox/bridge.patch b/pkgs/by-name/gu/gui-for-singbox/bridge.patch new file mode 100644 index 000000000000..d919c8b57ce9 --- /dev/null +++ b/pkgs/by-name/gu/gui-for-singbox/bridge.patch @@ -0,0 +1,34 @@ +--- old/bridge/bridge.go 2024-11-03 02:07:33.553972040 +0800 ++++ new/bridge/bridge.go 2024-11-03 02:10:09.239584378 +0800 +@@ -38,11 +38,6 @@ + + func InitBridge(fs embed.FS) { + // step1: Set Env +- exePath, err := os.Executable() +- if err != nil { +- panic(err) +- } +- + for _, v := range os.Args { + if v == "tasksch" { + Env.FromTaskSch = true +@@ -50,8 +45,8 @@ + } + } + +- Env.BasePath = filepath.Dir(exePath) +- Env.AppName = filepath.Base(exePath) ++ Env.AppName = "GUI.for.SingBox" ++ Env.BasePath = filepath.Join(os.Getenv("HOME"), ".config", Env.AppName) + + // step2: Create a persistent data symlink + if Env.OS == "darwin" { +@@ -128,7 +123,7 @@ + } + + func (a *App) RestartApp() FlagResult { +- exePath := Env.BasePath + "/" + Env.AppName ++ exePath := Env.AppName + + cmd := exec.Command(exePath) + HideExecWindow(cmd) diff --git a/pkgs/by-name/gu/gui-for-singbox/package.nix b/pkgs/by-name/gu/gui-for-singbox/package.nix new file mode 100644 index 000000000000..9531875fb418 --- /dev/null +++ b/pkgs/by-name/gu/gui-for-singbox/package.nix @@ -0,0 +1,133 @@ +{ + stdenv, + nodejs, + pnpm, + fetchFromGitHub, + buildGoModule, + lib, + wails, + webkitgtk_4_0, + pkg-config, + libsoup_3, + wrapGAppsHook3, + autoPatchelfHook, + makeDesktopItem, + copyDesktopItems, +}: +let + pname = "gui-for-singbox"; + version = "1.8.9"; + src = fetchFromGitHub { + owner = "GUI-for-Cores"; + repo = "GUI.for.SingBox"; + rev = "v${version}"; + hash = "sha256-mN+j2O/pM+kblmxZjVWvHXLHJSxydxLRh/Fol2+WALE="; + }; + frontend = stdenv.mkDerivation (finalAttrs: { + inherit pname version src; + + nativeBuildInputs = [ + nodejs + pnpm.configHook + ]; + + pnpmDeps = pnpm.fetchDeps { + inherit (finalAttrs) pname version src; + sourceRoot = "${finalAttrs.src.name}/frontend"; + hash = "sha256-bAgyGZLmEr8tMunoeQHl+B2IDGr4Gw3by1lC811lqio="; + }; + + sourceRoot = "${finalAttrs.src.name}/frontend"; + + buildPhase = '' + runHook preBuild + + pnpm run build + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir $out/ + cp -r ./dist/* $out/ + + runHook postInstall + ''; + + meta = { + description = "GUI program developed by vue3"; + license = with lib.licenses; [ gpl3Plus ]; + maintainers = with lib.maintainers; [ aucub ]; + platforms = lib.platforms.linux; + }; + }); +in +buildGoModule { + inherit pname version src; + + vendorHash = "sha256-rDbJOj8t/qu04Rd8J0LnXiBoIDmdzBQ9avAhImK7dFg="; + + nativeBuildInputs = [ + wails + pkg-config + wrapGAppsHook3 + autoPatchelfHook + copyDesktopItems + ]; + + buildInputs = [ + webkitgtk_4_0 + libsoup_3 + ]; + + desktopItems = [ + (makeDesktopItem { + name = "GUI.for.SingBox"; + exec = "GUI.for.SingBox"; + icon = "GUI.for.SingBox"; + genericName = "GUI.for.SingBox"; + desktopName = "GUI.for.SingBox"; + categories = [ + "Network" + ]; + keywords = [ + "Proxy" + ]; + }) + ]; + + postUnpack = '' + cp -r ${frontend} $sourceRoot/frontend/dist + ''; + + patches = [ ./bridge.patch ]; + + buildPhase = '' + runHook preBuild + + wails build -m -s -trimpath -skipbindings -devtools -tags webkit2_40 -o GUI.for.SingBox + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/share/pixmaps + cp -r ./build/bin $out/bin + cp build/appicon.png $out/share/pixmaps/GUI.for.SingBox.png + + runHook postInstall + ''; + + meta = { + description = "SingBox GUI program developed by vue3 + wails"; + homepage = "https://github.com/GUI-for-Cores/GUI.for.SingBox"; + mainProgram = "GUI.for.SingBox"; + license = with lib.licenses; [ gpl3Plus ]; + maintainers = with lib.maintainers; [ aucub ]; + platforms = lib.platforms.linux; + }; +}