nixpkgs/pkgs/tools/networking/sing-box/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
1.7 KiB
Nix
Raw Normal View History

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";
version = "1.9.4";
2022-12-28 07:44:35 +00:00
src = fetchFromGitHub {
owner = "SagerNet";
repo = pname;
rev = "v${version}";
hash = "sha256-+BQWmb09kCAjJioutD9xOWxQoZtBrTJFp0yAun/nDCc=";
2022-12-28 07:44:35 +00:00
};
vendorHash = "sha256-LCA59LijHLpM1bo4/yuFGrnk0g9DSXEZwmBUspGylV8=";
2022-12-28 07:44:35 +00:00
tags = [
"with_quic"
"with_dhcp"
2022-12-28 07:44:35 +00:00
"with_wireguard"
"with_ech"
"with_utls"
"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 ];
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-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
};
}