Skip to content

Commit

Permalink
gui-for-singbox: init at 1.8.9 (#351914)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 authored Nov 4, 2024
2 parents 29562e4 + 3ed37b7 commit 3287385
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkgs/by-name/gu/gui-for-singbox/bridge.patch
Original file line number Diff line number Diff line change
@@ -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)
133 changes: 133 additions & 0 deletions pkgs/by-name/gu/gui-for-singbox/package.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}

0 comments on commit 3287385

Please sign in to comment.