rio: 0.0.36 -> 0.0.37
[NixPkgs.git] / pkgs / tools / networking / sing-box / default.nix
blob7e47db4262c26ade89c5bc2790ca86fbd53d9212
1 { lib
2 , stdenv
3 , buildGoModule
4 , fetchFromGitHub
5 , installShellFiles
6 , buildPackages
7 , coreutils
8 , nix-update-script
9 , nixosTests
12 buildGoModule rec {
13   pname = "sing-box";
14   version = "1.8.13";
16   src = fetchFromGitHub {
17     owner = "SagerNet";
18     repo = pname;
19     rev = "v${version}";
20     hash = "sha256-BFkf+Gdej/AsIL89obHEwchrw4IcZqjEkr/suYKbVKY=";
21   };
23   vendorHash = "sha256-8OsUAknSuSJH1rRxMf8EVTUuIDHsIJauVI7hB4Fk1KU=";
25   tags = [
26     "with_quic"
27     "with_grpc"
28     "with_dhcp"
29     "with_wireguard"
30     "with_ech"
31     "with_utls"
32     "with_reality_server"
33     "with_acme"
34     "with_clash_api"
35     "with_v2ray_api"
36     "with_gvisor"
37   ];
39   subPackages = [
40     "cmd/sing-box"
41   ];
43   nativeBuildInputs = [ installShellFiles ];
45   ldflags = [
46     "-X=github.com/sagernet/sing-box/constant.Version=${version}"
47   ];
49   postInstall = let emulator = stdenv.hostPlatform.emulator buildPackages; in ''
50     installShellCompletion --cmd sing-box \
51       --bash <(${emulator} $out/bin/sing-box completion bash) \
52       --fish <(${emulator} $out/bin/sing-box completion fish) \
53       --zsh  <(${emulator} $out/bin/sing-box completion zsh )
55     substituteInPlace release/config/sing-box{,@}.service \
56       --replace-fail "/usr/bin/sing-box" "$out/bin/sing-box" \
57       --replace-fail "/bin/kill" "${coreutils}/bin/kill"
58     install -Dm444 -t "$out/lib/systemd/system/" release/config/sing-box{,@}.service
59   '';
61   passthru = {
62     updateScript = nix-update-script { };
63     tests = { inherit (nixosTests) sing-box; };
64   };
66   meta = with lib;{
67     homepage = "https://sing-box.sagernet.org";
68     description = "The universal proxy platform";
69     license = licenses.gpl3Plus;
70     maintainers = with maintainers; [ nickcao ];
71     mainProgram = "sing-box";
72   };