1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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;
};
})
|