2022-12-28 07:44:35 +00:00
|
|
|
{ lib
|
2022-12-28 09:39:42 +00:00
|
|
|
, stdenv
|
2022-12-28 07:44:35 +00:00
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
2022-12-28 09:39:42 +00:00
|
|
|
, installShellFiles
|
|
|
|
, buildPackages
|
2023-06-27 04:18:33 +00:00
|
|
|
, coreutils
|
2023-03-27 01:22:58 +00:00
|
|
|
, nix-update-script
|
2023-06-27 04:58:10 +00:00
|
|
|
, nixosTests
|
2022-12-28 07:44:35 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "sing-box";
|
2024-01-23 15:09:55 +00:00
|
|
|
version = "1.8.4";
|
2022-12-28 07:44:35 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "SagerNet";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2024-01-23 15:09:55 +00:00
|
|
|
hash = "sha256-Zn2akHyStq014k4ze3zsqASFnn6VTQ6fu1HdYMBDI1Y=";
|
2022-12-28 07:44:35 +00:00
|
|
|
};
|
|
|
|
|
2024-01-23 15:09:55 +00:00
|
|
|
vendorHash = "sha256-L5TFMwhxit4Bm6h6KSEygKxGHbflNa0UQ9lzNqsvuGA=";
|
2022-12-28 07:44:35 +00:00
|
|
|
|
|
|
|
tags = [
|
|
|
|
"with_quic"
|
|
|
|
"with_grpc"
|
2023-03-24 02:30:05 +00:00
|
|
|
"with_dhcp"
|
2022-12-28 07:44:35 +00:00
|
|
|
"with_wireguard"
|
|
|
|
"with_ech"
|
|
|
|
"with_utls"
|
2023-03-24 02:30:05 +00:00
|
|
|
"with_reality_server"
|
2022-12-28 07:44:35 +00:00
|
|
|
"with_acme"
|
|
|
|
"with_clash_api"
|
|
|
|
"with_v2ray_api"
|
|
|
|
"with_gvisor"
|
|
|
|
];
|
|
|
|
|
|
|
|
subPackages = [
|
|
|
|
"cmd/sing-box"
|
|
|
|
];
|
|
|
|
|
2022-12-28 09:39:42 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
|
2023-03-17 07:48:33 +00:00
|
|
|
ldflags = [
|
|
|
|
"-X=github.com/sagernet/sing-box/constant.Version=${version}"
|
|
|
|
];
|
|
|
|
|
2022-12-28 09:39:42 +00:00
|
|
|
postInstall = let emulator = stdenv.hostPlatform.emulator buildPackages; in ''
|
|
|
|
installShellCompletion --cmd sing-box \
|
|
|
|
--bash <(${emulator} $out/bin/sing-box completion bash) \
|
|
|
|
--fish <(${emulator} $out/bin/sing-box completion fish) \
|
|
|
|
--zsh <(${emulator} $out/bin/sing-box completion zsh )
|
2023-06-27 04:18:33 +00:00
|
|
|
|
|
|
|
substituteInPlace release/config/sing-box{,@}.service \
|
|
|
|
--replace "/usr/bin/sing-box" "$out/bin/sing-box" \
|
|
|
|
--replace "/bin/kill" "${coreutils}/bin/kill"
|
|
|
|
install -Dm444 -t "$out/lib/systemd/system/" release/config/sing-box{,@}.service
|
2022-12-28 09:39:42 +00:00
|
|
|
'';
|
|
|
|
|
2023-06-27 04:58:10 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = nix-update-script { };
|
|
|
|
tests = { inherit (nixosTests) sing-box; };
|
|
|
|
};
|
2023-03-27 01:22:58 +00:00
|
|
|
|
2022-12-28 07:44:35 +00:00
|
|
|
meta = with lib;{
|
|
|
|
homepage = "https://sing-box.sagernet.org";
|
|
|
|
description = "The universal proxy platform";
|
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
maintainers = with maintainers; [ nickcao ];
|
2023-12-30 14:40:07 +00:00
|
|
|
mainProgram = "sing-box";
|
2022-12-28 07:44:35 +00:00
|
|
|
};
|
|
|
|
}
|