diff --git a/pkgs/by-name/ne/nekoray/nekobox-core.nix b/pkgs/by-name/ne/nekoray/nekobox-core.nix deleted file mode 100644 index 43663ac9797e..000000000000 --- a/pkgs/by-name/ne/nekoray/nekobox-core.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - buildGoModule, - version, - src, - extraSources, -}: - -buildGoModule rec { - pname = "nekobox-core"; - inherit version src; - sourceRoot = "${src.name}/go/cmd/nekobox_core"; - - postPatch = '' - cp -r --no-preserve=all ${extraSources.libneko} ../../../../libneko - cp -r --no-preserve=all ${extraSources.sing-box-extra} ../../../../sing-box-extra - cp -r --no-preserve=all ${extraSources.sing-box} ../../../../sing-box - cp -r --no-preserve=all ${extraSources.sing-quic} ../../../../sing-quic - ''; - - vendorHash = "sha256-q/Co67AwJVElJnEY2O0SLLUzwlGiqazKu+fD/nnbrTk="; - - ldflags = [ - "-w" - "-s" - "-X github.com/matsuridayo/libneko/neko_common.Version_neko=${version}" - ]; - - tags = [ - "with_clash_api" - "with_gvisor" - "with_quic" - "with_wireguard" - "with_utls" - "with_ech" - ]; -} diff --git a/pkgs/by-name/ne/nekoray/nekoray-core.nix b/pkgs/by-name/ne/nekoray/nekoray-core.nix deleted file mode 100644 index 0488bc713e57..000000000000 --- a/pkgs/by-name/ne/nekoray/nekoray-core.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ - buildGoModule, - version, - src, - extraSources, -}: - -buildGoModule rec { - pname = "nekoray-core"; - inherit version src; - sourceRoot = "${src.name}/go/cmd/nekoray_core"; - - postPatch = '' - cp -r --no-preserve=all ${extraSources.libneko} ../../../../libneko - cp -r --no-preserve=all ${extraSources.Xray-core} ../../../../Xray-core - ''; - - vendorHash = "sha256-gxp5oI7qO+bdSe8Yrb9I4Wkl5TqqZeIhzcQDg1OpRkc="; - - ldflags = [ - "-w" - "-s" - "-X github.com/matsuridayo/libneko/neko_common.Version_neko=${version}" - "-X github.com/matsuridayo/libneko/neko_common.Version_v2ray=${extraSources.Xray-core.rev}" - ]; -} diff --git a/pkgs/by-name/ne/nekoray/package.nix b/pkgs/by-name/ne/nekoray/package.nix index 5b648feddb1c..d0e751d03f3c 100644 --- a/pkgs/by-name/ne/nekoray/package.nix +++ b/pkgs/by-name/ne/nekoray/package.nix @@ -1,111 +1,66 @@ { lib, stdenv, + + buildGoModule, fetchFromGitHub, - libsForQt5, + makeDesktopItem, + cmake, + copyDesktopItems, ninja, + + libcpr, protobuf, + qt6Packages, yaml-cpp, zxing-cpp, - callPackage, - makeDesktopItem, - copyDesktopItems, - v2ray-geoip, - v2ray-domain-list-community, sing-geoip, sing-geosite, }: -let - fetchSource = - args: - fetchFromGitHub ( - args - // { - owner = "MatsuriDayo"; - repo = args.name; - } - ); - - extraSources = { - # revs found in https://github.com/MatsuriDayo/nekoray/blob//libs/get_source_env.sh - Xray-core = fetchSource { - name = "Xray-core"; - rev = "01208225ee7e508044cca8eb6776a117bcecd997"; - hash = "sha256-R66i9MITdE9JlhD4wV0EitKPxyahQqDNpunUxVTmupA="; - }; - sing-box-extra = fetchSource { - name = "sing-box-extra"; - rev = "d31d6da26a51a929349e0d75fd89dccbe20d1268"; - hash = "sha256-YlzMAff8VOZGyCP7ksjcmoBDHT5llTYwwXIrs+qO5P4="; - }; - - # revs found in https://github.com/MatsuriDayo/sing-box-extra/blob//libs/get_source_env.sh - sing-box = fetchSource { - name = "sing-box"; - rev = "64f4eed2c667d9ff1e52a84233dee0e2ca32c17e"; - hash = "sha256-jIg/+fvTn46h6tE6YXtov+ZaBD/ywApTZbzHlT5v4lM="; - }; - sing-quic = fetchSource { - name = "sing-quic"; - rev = "e396733db4de15266f0cfdb43c392aca0759324a"; - hash = "sha256-un5NtZPRx1QAjwNhXkR9OVGldtfM1jQoNRUzt9oilUE="; - }; - libneko = fetchSource { - name = "libneko"; - rev = "5277a5bfc889ee7a89462695b0e678c1bd4909b1"; - hash = "sha256-6dlWDzI9ox4PQzEtJNgwA0pXmPC7fGrGId88Zl+1gpw="; - }; - }; - - geodata = { - "geoip.dat" = "${v2ray-geoip}/share/v2ray/geoip.dat"; - "geosite.dat" = "${v2ray-domain-list-community}/share/v2ray/geosite.dat"; - "geoip.db" = "${sing-geoip}/share/sing-box/geoip.db"; - "geosite.db" = "${sing-geosite}/share/sing-box/geosite.db"; - }; - - installGeodata = lib.concatStringsSep "\n" ( - lib.mapAttrsToList (filename: file: '' - install -Dm644 ${file} "$out/share/nekoray/${filename}" - '') geodata - ); -in stdenv.mkDerivation (finalAttrs: { pname = "nekoray"; - version = "3.26"; + version = "4.2.12"; - src = fetchSource { - name = "nekoray"; - rev = finalAttrs.version; - hash = "sha256-fDm6fCI6XA4DHKCN3zm9B7Qbdh3LTHYGK8fPmeEnhjI="; - fetchSubmodules = true; + src = fetchFromGitHub { + owner = "Mahdi-zarei"; + repo = "nekoray"; + tag = finalAttrs.version; + hash = "sha256-5BXrfNPBZ+smpniA1jOPWE0X/be/C9MzswfbwmWEnyQ="; }; strictDeps = true; nativeBuildInputs = [ - libsForQt5.wrapQtAppsHook cmake - ninja copyDesktopItems + ninja + qt6Packages.wrapQtAppsHook ]; buildInputs = [ - libsForQt5.qtbase - libsForQt5.qttools - libsForQt5.qtwayland - libsForQt5.qtx11extras + libcpr protobuf + qt6Packages.qtbase + qt6Packages.qttools yaml-cpp zxing-cpp ]; - # NKR_PACKAGE makes sure the app uses the user's config directory to store it's non-static content - # it's essentially the same as always setting the -appdata flag when running the program - cmakeFlags = [ (lib.cmakeBool "NKR_PACKAGE" true) ]; + cmakeFlags = [ + # makes sure the app uses the user's config directory to store it's non-static content + # it's essentially the same as always setting the -appdata flag when running the program + (lib.cmakeBool "NKR_PACKAGE" true) + ]; + + patches = [ + # if compiled with NKR_PACKAGE, nekoray assumes geoip.db and geosite.db will be found in ~/.config/nekoray + # we already package those two files in nixpkgs + # we can't place file at that location using our builder so we must change the search directory to be relative to the built executable + ./search-for-geodata-in-install-location.patch + ]; installPhase = '' runHook preInstall @@ -115,12 +70,11 @@ stdenv.mkDerivation (finalAttrs: { ln -s "$out/share/nekoray/nekoray" "$out/bin" # nekoray looks for other files and cores in the same directory it's located at - ln -s ${finalAttrs.passthru.nekoray-core}/bin/nekoray_core "$out/share/nekoray/nekoray_core" ln -s ${finalAttrs.passthru.nekobox-core}/bin/nekobox_core "$out/share/nekoray/nekobox_core" - ${installGeodata} - - install -Dm644 "$src/res/public/nekoray.png" "$out/share/icons/hicolor/256x256/apps/nekoray.png" + # our patch also makes nekoray look for geodata files next to the executable + ln -s ${sing-geoip}/share/sing-box/geoip.db "$out/share/nekoray/geoip.db" + ln -s ${sing-geosite}/share/sing-box/geosite.db "$out/share/nekoray/geosite.db" runHook postInstall ''; @@ -133,27 +87,38 @@ stdenv.mkDerivation (finalAttrs: { icon = "nekoray"; comment = finalAttrs.meta.description; terminal = false; - categories = [ - "Network" - "Application" - ]; + categories = [ "Network" ]; }) ]; - passthru = { - nekobox-core = callPackage ./nekobox-core.nix { - inherit (finalAttrs) src version; - inherit extraSources; - }; - nekoray-core = callPackage ./nekoray-core.nix { - inherit (finalAttrs) src version; - inherit extraSources; - }; + passthru.nekobox-core = buildGoModule { + pname = "nekobox-core"; + inherit (finalAttrs) version src; + sourceRoot = "${finalAttrs.src.name}/core/server"; + + vendorHash = "sha256-PDED6Haa3m2CZLij2A8Am7vSwep2YFrR984UNypduWo="; + + # ldflags and tags are taken from script/build_go.sh + ldflags = [ + "-w" + "-s" + "-X github.com/sagernet/sing-box/constant.Version=${finalAttrs.version}" + ]; + + tags = [ + "with_clash_api" + "with_gvisor" + "with_quic" + "with_wireguard" + "with_utls" + "with_ech" + "with_dhcp" + ]; }; meta = { description = "Qt based cross-platform GUI proxy configuration manager"; - homepage = "https://github.com/MatsuriDayo/nekoray"; + homepage = "https://github.com/Mahdi-zarei/nekoray"; license = lib.licenses.gpl3Plus; mainProgram = "nekoray"; maintainers = with lib.maintainers; [ tomasajt ]; diff --git a/pkgs/by-name/ne/nekoray/search-for-geodata-in-install-location.patch b/pkgs/by-name/ne/nekoray/search-for-geodata-in-install-location.patch new file mode 100644 index 000000000000..1af2e727bc41 --- /dev/null +++ b/pkgs/by-name/ne/nekoray/search-for-geodata-in-install-location.patch @@ -0,0 +1,13 @@ +diff --git a/src/global/NekoGui.cpp b/src/global/NekoGui.cpp +index d9be515..15de64b 100644 +--- a/src/global/NekoGui.cpp ++++ b/src/global/NekoGui.cpp +@@ -426,8 +426,6 @@ namespace NekoGui { + }; + + QString GetBasePath() { +- if (dataStore->flag_use_appdata) return QStandardPaths::writableLocation( +- QStandardPaths::AppConfigLocation); + return qApp->applicationDirPath(); + } +