internal: flake nix devshell clang/mold/openssl compatibility (#7855)

* fix: flake nix devshell clang/mold/openssl compatibility

- Add mold linker to buildInputs
- Pin cargo linker to clang 18 (stdenv's clang 21 causes SIGSEGV with mold)
- Embed OpenSSL rpath via rustflags instead of LD_LIBRARY_PATH to avoid leaking into git/ssh

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* more fixes

* fix

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
centdix
2026-02-09 15:03:22 +01:00
committed by GitHub
parent dc5e69481d
commit 76377a00a6
+14 -2
View File
@@ -55,8 +55,11 @@
nodejs
postgresql
pkg-config
clang
llvmPackages_18.clang
mold
cmake
cyrus_sasl
krb5
];
coursier = pkgs.fetchFromGitHub {
owner = "coursier";
@@ -66,7 +69,7 @@
};
PKG_CONFIG_PATH = pkgs.lib.makeSearchPath "lib/pkgconfig"
(with pkgs; [ openssl.dev libxml2.dev xmlsec.dev libxslt.dev ]);
(with pkgs; [ openssl.dev libxml2.dev xmlsec.dev libxslt.dev cyrus_sasl.dev krb5.dev ]);
RUSTY_V8_ARCHIVE = let
# NOTE: needs to be same as in Cargo.toml
version = "130.0.7";
@@ -303,6 +306,14 @@
# RUST_LOG = "debug";
# RUST_LOG = "kube=debug";
# Override cargo linker to use clang 18 (stdenv brings clang 21 which causes SIGSEGV with mold)
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.llvmPackages_18.clang}/bin/clang";
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.llvmPackages_18.clang}/bin/clang";
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS = "-C link-arg=-fuse-ld=mold -C link-arg=-Wl,-rpath,${pkgs.lib.makeLibraryPath [ pkgs.openssl pkgs.libffi pkgs.cyrus_sasl pkgs.krb5 pkgs.libxml2 pkgs.xmlsec pkgs.libxslt stdenv.cc.cc.lib ]}";
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS = "-C link-arg=-fuse-ld=mold -C link-arg=-Wl,-rpath,${pkgs.lib.makeLibraryPath [ pkgs.openssl pkgs.libffi pkgs.cyrus_sasl pkgs.krb5 pkgs.libxml2 pkgs.xmlsec pkgs.libxslt stdenv.cc.cc.lib ]}";
# rpath for build scripts and proc macros (host compilation)
CARGO_HOST_RUSTFLAGS = "-C link-arg=-Wl,-rpath,${pkgs.lib.makeLibraryPath [ pkgs.openssl pkgs.libffi pkgs.cyrus_sasl pkgs.krb5 pkgs.libxml2 pkgs.xmlsec pkgs.libxslt stdenv.cc.cc.lib ]}";
# See this issue: https://github.com/NixOS/nixpkgs/issues/370494
# Allows to build jemalloc on nixos
CFLAGS = "-Wno-error=int-conversion";
@@ -310,6 +321,7 @@
# Need to tell bindgen where to find libclang
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
# LD_LIBRARY_PATH set in shellHook with a wrapper to avoid leaking into git/ssh
# LD_LIBRARY_PATH = "${pkgs.gcc.lib}/lib";
# Set C flags for Rust's bindgen program. Unlike ordinary C