571c71e6f7
We are migrating packages that meet below requirements: 1. using `callPackage` 2. called path is a directory 3. overriding set is empty (`{ }`) 4. not containing path expressions other than relative path (to makenixpkgs-vet happy) 5. not referenced by nix files outside of the directory, other than`pkgs/top-level/all-packages.nix` 6. not referencing nix files outside of the directory 7. not referencing `default.nix` (since it's changed to `package.nix`) 8. `outPath` doesn't change after migration The tool is here: https://github.com/Aleksanaa/by-name-migrate.
72 lines
1.7 KiB
Nix
72 lines
1.7 KiB
Nix
{ lib
|
|
, stdenv
|
|
, buildGoModule
|
|
, fetchFromGitHub
|
|
, installShellFiles
|
|
, buildPackages
|
|
, coreutils
|
|
, nix-update-script
|
|
, nixosTests
|
|
}:
|
|
|
|
buildGoModule rec {
|
|
pname = "sing-box";
|
|
version = "1.10.1";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "SagerNet";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
hash = "sha256-WGlYaD4u9M1hfT+L6Adc5gClIYOkFsn4c9FAympmscQ=";
|
|
};
|
|
|
|
vendorHash = "sha256-lyZ2Up1SSaRGvai0gGtq43MSdHfXc2PuxflSbASYZ4A=";
|
|
|
|
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";
|
|
};
|
|
}
|