depot/third_party/nixpkgs/pkgs/tools/networking/sing-box/default.nix
Default email bcb2f287e1 Project import generated by Copybara.
GitOrigin-RevId: d603719ec6e294f034936c0d0dc06f689d91b6c3
2024-06-20 20:27:18 +05:30

71 lines
1.7 KiB
Nix

{ lib
, stdenv
, buildGoModule
, fetchFromGitHub
, installShellFiles
, buildPackages
, coreutils
, nix-update-script
, nixosTests
}:
buildGoModule rec {
pname = "sing-box";
version = "1.9.3";
src = fetchFromGitHub {
owner = "SagerNet";
repo = pname;
rev = "v${version}";
hash = "sha256-5T3Z5tayiKLeyP92Sgmxe3+QQW1QFIw3f+SF9qlr6bI=";
};
vendorHash = "sha256-UVFswS51OlYf01UJT7kqeCvmh3kGsiKet7tH/2AOkjc=";
tags = [
"with_quic"
"with_dhcp"
"with_wireguard"
"with_ech"
"with_utls"
"with_reality_server"
"with_acme"
"with_clash_api"
"with_gvisor"
];
subPackages = [
"cmd/sing-box"
];
nativeBuildInputs = [ installShellFiles ];
ldflags = [
"-X=github.com/sagernet/sing-box/constant.Version=${version}"
];
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 )
substituteInPlace release/config/sing-box{,@}.service \
--replace-fail "/usr/bin/sing-box" "$out/bin/sing-box" \
--replace-fail "/bin/kill" "${coreutils}/bin/kill"
install -Dm444 -t "$out/lib/systemd/system/" release/config/sing-box{,@}.service
'';
passthru = {
updateScript = nix-update-script { };
tests = { inherit (nixosTests) sing-box; };
};
meta = with lib;{
homepage = "https://sing-box.sagernet.org";
description = "Universal proxy platform";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ nickcao ];
mainProgram = "sing-box";
};
}