11{
22 lib ,
3- stdenv ,
43 buildGoModule ,
54 fetchFromGitHub ,
65 installShellFiles ,
7- buildPackages ,
86 coreutils ,
97 nix-update-script ,
108 nixosTests ,
119} :
1210
13- buildGoModule rec {
11+ buildGoModule ( finalAttrs : {
1412 pname = "sing-box" ;
1513 version = "1.11.11" ;
1614
1715 src = fetchFromGitHub {
1816 owner = "SagerNet" ;
19- repo = pname ;
20- rev = "v${ version } " ;
17+ repo = "sing-box" ;
18+ tag = "v${ finalAttrs . version } " ;
2119 hash = "sha256-hdYYjKBXnTqScYTUCfMmXozDD8GtIorLXnsU2Fmwg/c=" ;
2220 } ;
2321
@@ -42,35 +40,31 @@ buildGoModule rec {
4240 nativeBuildInputs = [ installShellFiles ] ;
4341
4442 ldflags = [
45- "-X=github.com/sagernet/sing-box/constant.Version=${ version } "
43+ "-X=github.com/sagernet/sing-box/constant.Version=${ finalAttrs . version } "
4644 ] ;
4745
48- postInstall =
49- let
50- emulator = stdenv . hostPlatform . emulator buildPackages ;
51- in
52- ''
53- installShellCompletion --cmd sing-box \
54- --bash <(${ emulator } $out/bin/sing-box completion bash) \
55- --fish <(${ emulator } $out/bin/sing-box completion fish) \
56- --zsh <(${ emulator } $out/bin/sing-box completion zsh )
46+ postInstall = ''
47+ installShellCompletion release/completions/sing-box.{bash,fish,zsh}
5748
58- substituteInPlace release/config/sing-box{,@}.service \
59- --replace-fail "/usr/bin/sing-box" "$out/bin/sing-box" \
60- --replace-fail "/bin/kill" "${ coreutils } /bin/kill"
61- install -Dm444 -t "$out/lib/systemd/system/" release/config/sing-box{,@}.service
62- '' ;
49+ substituteInPlace release/config/sing-box{,@}.service \
50+ --replace-fail "/usr/bin/sing-box" "$out/bin/sing-box" \
51+ --replace-fail "/bin/kill" "${ coreutils } /bin/kill"
52+ install -Dm444 -t "$out/lib/systemd/system/" release/config/sing-box{,@}.service
53+ '' ;
6354
6455 passthru = {
6556 updateScript = nix-update-script { } ;
6657 tests = { inherit ( nixosTests ) sing-box ; } ;
6758 } ;
6859
69- meta = with lib ; {
60+ meta = {
7061 homepage = "https://sing-box.sagernet.org" ;
7162 description = "Universal proxy platform" ;
72- license = licenses . gpl3Plus ;
73- maintainers = with maintainers ; [ nickcao ] ;
63+ license = lib . licenses . gpl3Plus ;
64+ maintainers = with lib . maintainers ; [
65+ nickcao
66+ prince213
67+ ] ;
7468 mainProgram = "sing-box" ;
7569 } ;
76- }
70+ } )
0 commit comments