packaging: use in-tree capnproto derivation

This is done because the one in nixpkgs has several problems and we
don't want to conflict with them fixing those problems:
- not building shared libs
- not building debuginfo (more critical for us due to
  lix-project/lix#549)
- not setting the correct cmake build type
- not setting the correct cxxflags to build the coroutine library
- not building with clang (required for the coroutine library since gcc
  is known to miscompile coroutines *in kj*).

CC: lix-project/lix#551

Fixes: lix-project/lix#550
Change-Id: Ia5b78dc1809963fdd1a8203b127a216cb575d751
This commit is contained in:
jade 2024-10-15 15:47:00 -07:00
parent 77b6f6734f
commit ca55060ac6
2 changed files with 64 additions and 3 deletions

60
misc/capnproto.nix Normal file
View file

@ -0,0 +1,60 @@
# FIXME: upstream to nixpkgs (do NOT build with gcc due to gcc coroutine bugs)
{
lib,
stdenv,
fetchFromGitHub,
cmake,
openssl,
zlib,
}:
assert stdenv.cc.isClang;
stdenv.mkDerivation rec {
pname = "capnproto";
version = "1.0.2";
# release tarballs are missing some ekam rules
src = fetchFromGitHub {
owner = "capnproto";
repo = "capnproto";
rev = "v${version}";
sha256 = "sha256-LVdkqVBTeh8JZ1McdVNtRcnFVwEJRNjt0JV2l7RkuO8=";
};
nativeBuildInputs = [ cmake ];
propagatedBuildInputs = [
openssl
zlib
];
# FIXME: separate the binaries from the stuff that user systems actually use
# This runs into a terrible UX issue in Lix and I just don't want to debug it
# right now for the couple MB of closure size:
# https://git.lix.systems/lix-project/lix/issues/551
# outputs = [ "bin" "dev" "out" ];
cmakeFlags = [
(lib.cmakeBool "BUILD_SHARED_LIBS" true)
# Take optimization flags from CXXFLAGS rather than cmake injecting them
(lib.cmakeFeature "CMAKE_BUILD_TYPE" "None")
];
env = {
# Required to build the coroutine library
CXXFLAGS = "-std=c++20";
};
separateDebugInfo = true;
meta = with lib; {
homepage = "https://capnproto.org/";
description = "Cap'n Proto cerealization protocol";
longDescription = ''
Capn Proto is an insanely fast data interchange format and
capability-based RPC system. Think JSON, except binary. Or think Protocol
Buffers, except faster.
'';
license = licenses.mit;
platforms = platforms.all;
maintainers = lib.teams.lix.members;
};
}

View file

@ -16,7 +16,6 @@
bzip2, bzip2,
callPackage, callPackage,
capnproto-lix ? __forDefaults.capnproto-lix, capnproto-lix ? __forDefaults.capnproto-lix,
capnproto,
cmake, cmake,
curl, curl,
doxygen, doxygen,
@ -106,8 +105,9 @@
build-release-notes = callPackage ./maintainers/build-release-notes.nix { }; build-release-notes = callPackage ./maintainers/build-release-notes.nix { };
# needs explicit c++20 to enable coroutine support # needs derivation patching to add debuginfo and coroutine library support
capnproto-lix = capnproto.overrideAttrs { CXXFLAGS = "-std=c++20"; }; # !! must build this with clang as it is affected by the gcc coroutine bugs
capnproto-lix = callPackage ./misc/capnproto.nix { inherit stdenv; };
}, },
}: }:
@ -449,6 +449,7 @@ stdenv.mkDerivation (finalAttrs: {
editline-lix editline-lix
build-release-notes build-release-notes
pegtl pegtl
capnproto-lix
; ;
# The collection of dependency logic for this derivation is complicated enough that # The collection of dependency logic for this derivation is complicated enough that