about summary refs log tree commit diff
path: root/pkgs/by-name/ne
diff options
context:
space:
mode:
authorToma <62384384+TomaSajt@users.noreply.github.com>2024-04-10 03:48:55 +0200
committerGitHub <noreply@github.com>2024-04-10 09:48:55 +0800
commitb95f829e428ee903d0c877bf2f4b01ae2ddcec55 (patch)
tree132020a6f78a5c987aa09dac080f29dbc7974ea0 /pkgs/by-name/ne
parentd2fc79dbeb70cdc461a7a1a9cef1baf630c9c781 (diff)
nekoray: init at 3.26 (#300794)
* nekoray: init at 3.26

* nekoray: limit meta.platforms to linux

---------

Co-authored-by: Aleksana <alexander.huang.y@gmail.com>
Diffstat (limited to 'pkgs/by-name/ne')
-rw-r--r--pkgs/by-name/ne/nekoray/nekobox-core.nix36
-rw-r--r--pkgs/by-name/ne/nekoray/nekoray-core.nix26
-rw-r--r--pkgs/by-name/ne/nekoray/package.nix159
3 files changed, 221 insertions, 0 deletions
diff --git a/pkgs/by-name/ne/nekoray/nekobox-core.nix b/pkgs/by-name/ne/nekoray/nekobox-core.nix
new file mode 100644
index 0000000000000..43663ac9797ec
--- /dev/null
+++ b/pkgs/by-name/ne/nekoray/nekobox-core.nix
@@ -0,0 +1,36 @@
+{
+  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
new file mode 100644
index 0000000000000..0488bc713e574
--- /dev/null
+++ b/pkgs/by-name/ne/nekoray/nekoray-core.nix
@@ -0,0 +1,26 @@
+{
+  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
new file mode 100644
index 0000000000000..4a1ce8f046620
--- /dev/null
+++ b/pkgs/by-name/ne/nekoray/package.nix
@@ -0,0 +1,159 @@
+{
+  lib,
+  stdenv,
+  fetchFromGitHub,
+  libsForQt5,
+  cmake,
+  ninja,
+  protobuf,
+  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/<version>/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/<sing-box-extra.rev>/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";
+
+  src = fetchSource {
+    name = "nekoray";
+    rev = finalAttrs.version;
+    hash = "sha256-fDm6fCI6XA4DHKCN3zm9B7Qbdh3LTHYGK8fPmeEnhjI=";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [
+    libsForQt5.wrapQtAppsHook
+    cmake
+    ninja
+    protobuf
+    copyDesktopItems
+  ];
+
+  buildInputs = [
+    libsForQt5.qtbase
+    libsForQt5.qttools
+    libsForQt5.qtx11extras
+    zxing-cpp
+    yaml-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) ];
+
+  installPhase = ''
+    runHook preInstall
+
+    install -Dm755 nekoray "$out/share/nekoray/nekoray"
+    mkdir -p "$out/bin"
+    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"
+
+    runHook postInstall
+  '';
+
+  desktopItems = [
+    (makeDesktopItem {
+      name = "nekoray";
+      desktopName = "nekoray";
+      exec = "nekoray";
+      icon = "nekoray";
+      comment = finalAttrs.meta.description;
+      terminal = false;
+      categories = [
+        "Network"
+        "Application"
+      ];
+    })
+  ];
+
+  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;
+    };
+  };
+
+  meta = {
+    description = "Qt based cross-platform GUI proxy configuration manager";
+    homepage = "https://github.com/MatsuriDayo/nekoray";
+    license = lib.licenses.gpl3Plus;
+    mainProgram = "nekoray";
+    maintainers = with lib.maintainers; [ tomasajt ];
+    platforms = lib.platforms.linux;
+  };
+})