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-05-15 15:35:15 +00:00
|
|
|
version = "1.8.13";
|
2023-01-11 07:51:40 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "SagerNet";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2024-05-15 15:35:15 +00:00
|
|
|
hash = "sha256-BFkf+Gdej/AsIL89obHEwchrw4IcZqjEkr/suYKbVKY=";
|
2023-01-11 07:51:40 +00:00
|
|
|
};
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
vendorHash = "sha256-8OsUAknSuSJH1rRxMf8EVTUuIDHsIJauVI7hB4Fk1KU=";
|
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 \
|
2024-04-21 15:54:59 +00:00
|
|
|
--replace-fail "/usr/bin/sing-box" "$out/bin/sing-box" \
|
|
|
|
--replace-fail "/bin/kill" "${coreutils}/bin/kill"
|
2023-07-15 17:15:38 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|