From 1b125a40d6a28d377007586be725f10f53327216 Mon Sep 17 00:00:00 2001 From: aucub <78630225+aucub@users.noreply.github.com> Date: Wed, 25 Dec 2024 23:01:07 +0800 Subject: [PATCH] gui-for-singbox: 1.8.9 -> 1.9.0 --- pkgs/by-name/gu/gui-for-singbox/bridge.patch | 17 +++++--- pkgs/by-name/gu/gui-for-singbox/package.nix | 41 +++++++++++--------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/pkgs/by-name/gu/gui-for-singbox/bridge.patch b/pkgs/by-name/gu/gui-for-singbox/bridge.patch index d919c8b57ce9..e31a6d9c7512 100644 --- a/pkgs/by-name/gu/gui-for-singbox/bridge.patch +++ b/pkgs/by-name/gu/gui-for-singbox/bridge.patch @@ -1,5 +1,5 @@ ---- old/bridge/bridge.go 2024-11-03 02:07:33.553972040 +0800 -+++ new/bridge/bridge.go 2024-11-03 02:10:09.239584378 +0800 +--- a/bridge/bridge.go 2024-12-25 20:53:45.504021585 +0000 ++++ b/bridge/bridge.go 2024-12-25 21:02:20.318422528 +0000 @@ -38,11 +38,6 @@ func InitBridge(fs embed.FS) { @@ -12,23 +12,28 @@ for _, v := range os.Args { if v == "tasksch" { Env.FromTaskSch = true -@@ -50,8 +45,8 @@ +@@ -50,8 +45,13 @@ } } - 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) ++ xdgDataHome := os.Getenv("XDG_DATA_HOME") ++ if xdgDataHome == "" { ++ homeDir, _ := os.UserHomeDir() ++ xdgDataHome = filepath.Join(homeDir, ".local", "share") ++ } ++ Env.BasePath = filepath.Join(xdgDataHome, Env.AppName) // step2: Create a persistent data symlink if Env.OS == "darwin" { -@@ -128,7 +123,7 @@ +@@ -128,7 +128,7 @@ } func (a *App) RestartApp() FlagResult { - exePath := Env.BasePath + "/" + Env.AppName -+ exePath := Env.AppName ++ exePath := "@basepath@/bin" + "/" + 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 index 9531875fb418..be491136b5b9 100644 --- a/pkgs/by-name/gu/gui-for-singbox/package.nix +++ b/pkgs/by-name/gu/gui-for-singbox/package.nix @@ -9,20 +9,22 @@ webkitgtk_4_0, pkg-config, libsoup_3, - wrapGAppsHook3, autoPatchelfHook, makeDesktopItem, copyDesktopItems, + replaceVars, }: let pname = "gui-for-singbox"; - version = "1.8.9"; + version = "1.9.0"; + src = fetchFromGitHub { owner = "GUI-for-Cores"; repo = "GUI.for.SingBox"; - rev = "v${version}"; - hash = "sha256-mN+j2O/pM+kblmxZjVWvHXLHJSxydxLRh/Fol2+WALE="; + tag = "v${version}"; + hash = "sha256-5zd4CVWVR+E3E097Xjd/V6QFRV9Ye2UQvBalAQ9zqXc="; }; + frontend = stdenv.mkDerivation (finalAttrs: { inherit pname version src; @@ -34,7 +36,7 @@ let pnpmDeps = pnpm.fetchDeps { inherit (finalAttrs) pname version src; sourceRoot = "${finalAttrs.src.name}/frontend"; - hash = "sha256-bAgyGZLmEr8tMunoeQHl+B2IDGr4Gw3by1lC811lqio="; + hash = "sha256-dLI1YMzs9lLk9lJBkBgc6cpirM79khy0g5VaOVEzUAc="; }; sourceRoot = "${finalAttrs.src.name}/frontend"; @@ -42,7 +44,7 @@ let buildPhase = '' runHook preBuild - pnpm run build + pnpm run build-only runHook postBuild ''; @@ -50,8 +52,7 @@ let installPhase = '' runHook preInstall - mkdir $out/ - cp -r ./dist/* $out/ + cp -r ./dist $out runHook postInstall ''; @@ -67,12 +68,17 @@ in buildGoModule { inherit pname version src; - vendorHash = "sha256-rDbJOj8t/qu04Rd8J0LnXiBoIDmdzBQ9avAhImK7dFg="; + patches = [ + (replaceVars ./bridge.patch { + basepath = placeholder "out"; + }) + ]; + + vendorHash = "sha256-OrysyJF+lUMf+0vWmOZHjxUdE6fQCKArmpV4alXxtYs="; nativeBuildInputs = [ wails pkg-config - wrapGAppsHook3 autoPatchelfHook copyDesktopItems ]; @@ -84,9 +90,9 @@ buildGoModule { desktopItems = [ (makeDesktopItem { - name = "GUI.for.SingBox"; + name = "gui-for-singbox"; exec = "GUI.for.SingBox"; - icon = "GUI.for.SingBox"; + icon = "gui-for-singbox"; genericName = "GUI.for.SingBox"; desktopName = "GUI.for.SingBox"; categories = [ @@ -98,12 +104,10 @@ buildGoModule { }) ]; - postUnpack = '' - cp -r ${frontend} $sourceRoot/frontend/dist + preBuild = '' + cp -r ${frontend} ./frontend/dist ''; - patches = [ ./bridge.patch ]; - buildPhase = '' runHook preBuild @@ -115,9 +119,8 @@ buildGoModule { 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 + install -Dm 0755 ./build/bin/GUI.for.SingBox $out/bin/GUI.for.SingBox + install -Dm 0644 build/appicon.png $out/share/pixmaps/gui-for-singbox.png runHook postInstall '';