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-08-19 04:32:27 +00:00
|
|
|
version = "1.9.4";
|
2022-12-28 07:44:35 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "SagerNet";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2024-08-19 04:32:27 +00:00
|
|
|
hash = "sha256-+BQWmb09kCAjJioutD9xOWxQoZtBrTJFp0yAun/nDCc=";
|
2022-12-28 07:44:35 +00:00
|
|
|
};
|
|
|
|
|
2024-08-19 04:32:27 +00:00
|
|
|
vendorHash = "sha256-LCA59LijHLpM1bo4/yuFGrnk0g9DSXEZwmBUspGylV8=";
|
2022-12-28 07:44:35 +00:00
|
|
|
|
|
|
|
tags = [
|
|
|
|
"with_quic"
|
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_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 \
|
2024-04-08 18:19:05 +00:00
|
|
|
--replace-fail "/usr/bin/sing-box" "$out/bin/sing-box" \
|
|
|
|
--replace-fail "/bin/kill" "${coreutils}/bin/kill"
|
2023-06-27 04:18:33 +00:00
|
|
|
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 = "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
|
|
|
};
|
|
|
|
}
|