2021-02-05 17:12:51 +00:00
|
|
|
{ lib
|
2022-09-09 14:08:57 +00:00
|
|
|
, bazel_5
|
2021-02-05 17:12:51 +00:00
|
|
|
, buildBazelPackage
|
2021-01-17 00:15:33 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, stdenv
|
|
|
|
, cmake
|
2021-06-28 23:13:55 +00:00
|
|
|
, gn
|
2021-01-17 00:15:33 +00:00
|
|
|
, go
|
2021-06-28 23:13:55 +00:00
|
|
|
, jdk
|
2021-01-17 00:15:33 +00:00
|
|
|
, ninja
|
2022-09-09 14:08:57 +00:00
|
|
|
, patchelf
|
2021-01-17 00:15:33 +00:00
|
|
|
, python3
|
2022-03-05 16:20:37 +00:00
|
|
|
, linuxHeaders
|
2021-04-05 15:23:46 +00:00
|
|
|
, nixosTests
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
# v8 (upstream default), wavm, wamr, wasmtime, disabled
|
|
|
|
, wasmRuntime ? "wamr"
|
2021-01-17 00:15:33 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
srcVer = {
|
|
|
|
# We need the commit hash, since Bazel stamps the build with it.
|
|
|
|
# However, the version string is more useful for end-users.
|
|
|
|
# These are contained in a attrset of their own to make it obvious that
|
|
|
|
# people should update both.
|
2022-09-09 14:08:57 +00:00
|
|
|
version = "1.23.1";
|
|
|
|
rev = "edd69583372955fdfa0b8ca3820dd7312c094e46";
|
2021-01-17 00:15:33 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
buildBazelPackage rec {
|
|
|
|
pname = "envoy";
|
2022-03-05 16:20:37 +00:00
|
|
|
inherit (srcVer) version;
|
2022-09-09 14:08:57 +00:00
|
|
|
bazel = bazel_5;
|
2021-01-17 00:15:33 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "envoyproxy";
|
|
|
|
repo = "envoy";
|
2022-04-27 09:35:20 +00:00
|
|
|
inherit (srcVer) rev;
|
2022-09-09 14:08:57 +00:00
|
|
|
sha256 = "sha256:157dbmp479xv5507n48yibvlgi2ac0l3sl9rzm28cm9lhzwva3k0";
|
2021-01-17 00:15:33 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
postFetch = ''
|
2021-01-17 00:15:33 +00:00
|
|
|
chmod -R +w $out
|
|
|
|
rm $out/.bazelversion
|
2022-03-05 16:20:37 +00:00
|
|
|
echo ${srcVer.rev} > $out/SOURCE_VERSION
|
2021-01-17 00:15:33 +00:00
|
|
|
sed -i 's/GO_VERSION = ".*"/GO_VERSION = "host"/g' $out/bazel/dependency_imports.bzl
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
sed -i 's,#!/usr/bin/env python3,#!${python3}/bin/python,' bazel/foreign_cc/luajit.patch
|
2021-06-28 23:13:55 +00:00
|
|
|
sed -i '/javabase=/d' .bazelrc
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
# Use system Python.
|
|
|
|
sed -i -e '/python_interpreter_target =/d' -e '/@python3_10/d' bazel/python_dependencies.bzl
|
2021-01-17 00:15:33 +00:00
|
|
|
'';
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
patches = [
|
2022-04-27 09:35:20 +00:00
|
|
|
# fix issues with brotli and GCC 11.2.0+ (-Werror=vla-parameter)
|
|
|
|
./bump-brotli.patch
|
|
|
|
|
|
|
|
# fix linux-aarch64 WAMR builds
|
|
|
|
# (upstream WAMR only detects aarch64 on Darwin, not Linux)
|
|
|
|
./fix-aarch64-wamr.patch
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
# use system Python, not bazel-fetched binary Python
|
|
|
|
./use-system-python.patch
|
2022-03-05 16:20:37 +00:00
|
|
|
];
|
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
python3
|
2021-06-28 23:13:55 +00:00
|
|
|
gn
|
2021-01-17 00:15:33 +00:00
|
|
|
go
|
2021-06-28 23:13:55 +00:00
|
|
|
jdk
|
2021-01-17 00:15:33 +00:00
|
|
|
ninja
|
2022-09-09 14:08:57 +00:00
|
|
|
patchelf
|
2021-01-17 00:15:33 +00:00
|
|
|
];
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
buildInputs = [
|
|
|
|
linuxHeaders
|
|
|
|
];
|
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
fetchAttrs = {
|
2022-04-27 09:35:20 +00:00
|
|
|
sha256 = {
|
2022-09-09 14:08:57 +00:00
|
|
|
x86_64-linux = "0y3gpvx148bnn6kljdvkg99m681vw39l0avrhvncbf62hvpifqkw";
|
|
|
|
aarch64-linux = "0lln5mdlskahz5hb4w268ys2ksy3051drrwlhracmk4i7rpm7fq3";
|
2022-04-27 09:35:20 +00:00
|
|
|
}.${stdenv.system} or (throw "unsupported system ${stdenv.system}");
|
2021-01-17 00:15:33 +00:00
|
|
|
dontUseCmakeConfigure = true;
|
2021-06-28 23:13:55 +00:00
|
|
|
dontUseGnConfigure = true;
|
2021-01-17 00:15:33 +00:00
|
|
|
preInstall = ''
|
|
|
|
# Strip out the path to the build location (by deleting the comment line).
|
|
|
|
find $bazelOut/external -name requirements.bzl | while read requirements; do
|
|
|
|
sed -i '/# Generated from /d' "$requirements"
|
|
|
|
done
|
2022-09-09 14:08:57 +00:00
|
|
|
find $bazelOut/external -type f -executable | while read execbin; do
|
|
|
|
file "$execbin" | grep -q ': ELF .*, dynamically linked,' || continue
|
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \
|
|
|
|
"$execbin"
|
|
|
|
done
|
2021-01-17 00:15:33 +00:00
|
|
|
|
|
|
|
# Remove references to paths in the Nix store.
|
|
|
|
sed -i \
|
|
|
|
-e 's,${python3},__NIXPYTHON__,' \
|
|
|
|
-e 's,${stdenv.shellPackage},__NIXSHELL__,' \
|
|
|
|
$bazelOut/external/com_github_luajit_luajit/build.py \
|
|
|
|
$bazelOut/external/local_config_sh/BUILD
|
|
|
|
rm -r $bazelOut/external/go_sdk
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
# Remove Unix timestamps from go cache.
|
|
|
|
rm -rf $bazelOut/external/bazel_gazelle_go_repository_cache/{gocache,pkg/mod/cache,pkg/sumdb}
|
2021-01-17 00:15:33 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
buildAttrs = {
|
|
|
|
dontUseCmakeConfigure = true;
|
2021-06-28 23:13:55 +00:00
|
|
|
dontUseGnConfigure = true;
|
2021-01-17 00:15:33 +00:00
|
|
|
dontUseNinjaInstall = true;
|
|
|
|
preConfigure = ''
|
2022-03-05 16:20:37 +00:00
|
|
|
sed -i 's,#!/usr/bin/env bash,#!${stdenv.shell},' $bazelOut/external/rules_foreign_cc/foreign_cc/private/framework/toolchains/linux_commands.bzl
|
2021-01-17 00:15:33 +00:00
|
|
|
|
|
|
|
# Add paths to Nix store back.
|
|
|
|
sed -i \
|
|
|
|
-e 's,__NIXPYTHON__,${python3},' \
|
|
|
|
-e 's,__NIXSHELL__,${stdenv.shellPackage},' \
|
|
|
|
$bazelOut/external/com_github_luajit_luajit/build.py \
|
|
|
|
$bazelOut/external/local_config_sh/BUILD
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm0755 bazel-bin/source/exe/envoy-static $out/bin/envoy
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
removeRulesCC = false;
|
|
|
|
removeLocalConfigCc = true;
|
|
|
|
removeLocal = false;
|
|
|
|
bazelTarget = "//source/exe:envoy-static";
|
|
|
|
bazelBuildFlags = [
|
|
|
|
"-c opt"
|
|
|
|
"--spawn_strategy=standalone"
|
|
|
|
"--noexperimental_strict_action_env"
|
|
|
|
"--cxxopt=-Wno-maybe-uninitialized"
|
|
|
|
"--cxxopt=-Wno-uninitialized"
|
2022-04-27 09:35:20 +00:00
|
|
|
"--cxxopt=-Wno-error=type-limits"
|
2022-09-09 14:08:57 +00:00
|
|
|
"--cxxopt=-Wno-error=range-loop-construct"
|
|
|
|
|
|
|
|
# Force use of system Java.
|
|
|
|
"--extra_toolchains=@local_jdk//:all"
|
|
|
|
"--java_runtime_version=local_jdk"
|
|
|
|
"--tool_java_runtime_version=local_jdk"
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
"--define=wasm=${wasmRuntime}"
|
|
|
|
];
|
|
|
|
bazelFetchFlags = [
|
|
|
|
"--define=wasm=${wasmRuntime}"
|
2021-01-17 00:15:33 +00:00
|
|
|
];
|
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
passthru.tests = {
|
2022-04-15 01:41:22 +00:00
|
|
|
envoy = nixosTests.envoy;
|
|
|
|
# tested as a core component of Pomerium
|
|
|
|
pomerium = nixosTests.pomerium;
|
2021-04-05 15:23:46 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2021-01-17 00:15:33 +00:00
|
|
|
homepage = "https://envoyproxy.io";
|
|
|
|
description = "Cloud-native edge and service proxy";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ lukegb ];
|
2022-04-27 09:35:20 +00:00
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" ];
|
2021-01-17 00:15:33 +00:00
|
|
|
};
|
|
|
|
}
|