2023-01-11 07:51:40 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
|
|
|
, buildPackages
|
2023-07-15 17:15:38 +00:00
|
|
|
, coreutils
|
2023-04-12 12:48:02 +00:00
|
|
|
, nix-update-script
|
2023-07-15 17:15:38 +00:00
|
|
|
, nixosTests
|
2023-01-11 07:51:40 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "sing-box";
|
2024-02-29 20:09:43 +00:00
|
|
|
version = "1.8.7";
|
2023-01-11 07:51:40 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "SagerNet";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2024-02-29 20:09:43 +00:00
|
|
|
hash = "sha256-SZd67DyDsKZZ9hKgRtbQLJzfft+vl49k9J/+Xv8ghHs=";
|
2023-01-11 07:51:40 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
vendorHash = "sha256-9aH8KHn+8brGT/eJS9SWVYBMxDI1R3Q+pORfnjUI7ms=";
|
2023-01-11 07:51:40 +00:00
|
|
|
|
|
|
|
tags = [
|
|
|
|
"with_quic"
|
|
|
|
"with_grpc"
|
2023-03-27 19:17:25 +00:00
|
|
|
"with_dhcp"
|
2023-01-11 07:51:40 +00:00
|
|
|
"with_wireguard"
|
|
|
|
"with_ech"
|
|
|
|
"with_utls"
|
2023-03-27 19:17:25 +00:00
|
|
|
"with_reality_server"
|
2023-01-11 07:51:40 +00:00
|
|
|
"with_acme"
|
|
|
|
"with_clash_api"
|
|
|
|
"with_v2ray_api"
|
|
|
|
"with_gvisor"
|
|
|
|
];
|
|
|
|
|
|
|
|
subPackages = [
|
|
|
|
"cmd/sing-box"
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
ldflags = [
|
|
|
|
"-X=github.com/sagernet/sing-box/constant.Version=${version}"
|
|
|
|
];
|
|
|
|
|
2023-01-11 07:51:40 +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-07-15 17:15:38 +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
|
2023-01-11 07:51:40 +00:00
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = nix-update-script { };
|
|
|
|
tests = { inherit (nixosTests) sing-box; };
|
|
|
|
};
|
2023-04-12 12:48:02 +00:00
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
meta = with lib;{
|
|
|
|
homepage = "https://sing-box.sagernet.org";
|
|
|
|
description = "The universal proxy platform";
|
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
maintainers = with maintainers; [ nickcao ];
|
2024-01-02 11:29:13 +00:00
|
|
|
mainProgram = "sing-box";
|
2023-01-11 07:51:40 +00:00
|
|
|
};
|
|
|
|
}
|