-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.nix
94 lines (90 loc) · 1.88 KB
/
package.nix
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
{
lib,
platforms,
src,
buildGoModule,
go,
runCommand,
version,
lastModifiedDate,
rev,
}:
buildGoModule rec {
inherit version src;
pname = "hysteria";
modRoot = "./app";
vendorHash = "sha256-IRdC+imF4MwER9ZSH5vQnm3hu7jqNw5Pfi62JU6Y9l8=";
env.GOWORK = "off";
ldflags =
let
inherit (builtins)
elemAt
readFile
split
match
;
cmd = "github.com/apernet/hysteria/app/v2/cmd";
goVersion = (
elemAt (match ".*(go.*)\n" (
readFile (runCommand "go-version.txt" { } "${go}/bin/go version > $out")
)) 0
);
goPlatform = index: elemAt (split "/" (elemAt (split " " goVersion) 2)) index;
in
[
"-s"
"-w"
]
++ builtins.map (list: "-X '${cmd}.${builtins.elemAt list 0}=${builtins.elemAt list 1}'") [
[
"libVersion"
(elemAt (split "\n" (
elemAt (match ".*github.com\/apernet\/quic-go (.*)" (readFile (src + "/core/go.mod"))) 0
)) 0)
]
[
"appVersion"
version
]
[
"appDate"
lastModifiedDate
]
[
"appType"
"release"
]
[
"appCommit"
rev
]
[
"appPlatform"
(goPlatform 0)
]
[
"appArch"
(goPlatform 2)
]
[
"appToolchain"
goVersion
]
];
patchPhase = ''
rm app/internal/http/server_test.go \
app/internal/sockopts/sockopts_linux_test.go \
app/internal/socks5/server_test.go \
app/internal/utils/certloader_test.go
'';
postInstall = ''
mv $out/bin/app $out/bin/hysteria
'';
meta = with lib; {
inherit platforms;
mainProgram = "hysteria";
description = "A powerful, lightning fast and censorship resistant proxy.";
homepage = "https://v2.hysteria.network/";
license = licenses.mit;
};
}