From e349515a7f47ae722b6285179f5c75fe125d51bd Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 28 Jan 2026 17:22:19 -0500 Subject: [PATCH 1/2] fix build on linux --- nix/bin.nix | 58 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/nix/bin.nix b/nix/bin.nix index be3e3e7..6ac2eeb 100644 --- a/nix/bin.nix +++ b/nix/bin.nix @@ -1,38 +1,58 @@ # Extracts binaries from the shared build { pkgs, common, build, lib }: -pkgs.runCommand "${common.pname}-bin-${common.version}" - { - inherit (common) meta; - nativeBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.darwin.cctools ]; - } - '' +pkgs.stdenvNoCC.mkDerivation { + pname = "${common.pname}-bin"; + version = common.version; + + # No source to unpack - we're copying from another derivation + dontUnpack = true; + + nativeBuildInputs = + [ pkgs.qt6.wrapQtAppsNoGuiHook ] ++ # Wrap CLI apps to be immune to LD_LIBRARY_PATH pollution + pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.darwin.cctools ] ++ + pkgs.lib.optionals pkgs.stdenv.isLinux [ pkgs.autoPatchelfHook ]; + + # Clear LD_LIBRARY_PATH to prevent external Qt installations from interfering + qtWrapperArgs = [ "--unset LD_LIBRARY_PATH" ]; + + # autoPatchelfHook uses buildInputs to find libraries (zstd, Qt, etc.) + buildInputs = pkgs.lib.optionals pkgs.stdenv.isLinux common.buildInputs; + + installPhase = '' + runHook preInstall + # Copy binaries from the shared build mkdir -p $out/bin if [ -d ${build}/bin ]; then cp -r ${build}/bin/* $out/bin/ + chmod -R +w $out/bin # Make writable so autoPatchelf can modify fi # Also include libraries in lib path for runtime linking mkdir -p $out/lib if [ -d ${lib}/lib ]; then cp -r ${lib}/lib/* $out/lib/ + chmod -R +w $out/lib # Make writable if needed fi - # Fix rpaths for all binaries to find the libraries + runHook postInstall + ''; + + # macOS-specific fixup (autoPatchelfHook handles Linux automatically) + postFixup = pkgs.lib.optionalString pkgs.stdenv.isDarwin '' + # On macOS, use install_name_tool to fix the library paths for binary in $out/bin/*; do if [ -f "$binary" ] && [ -x "$binary" ]; then - : - ${pkgs.lib.optionalString pkgs.stdenv.isDarwin '' - # On macOS, use install_name_tool to fix the library paths - for dylib in $out/lib/*.dylib; do - if [ -f "$dylib" ]; then - libname=$(basename $dylib) - install_name_tool -change "@rpath/$libname" "$out/lib/$libname" "$binary" 2>/dev/null || true - fi - done - ''} + for dylib in $out/lib/*.dylib; do + if [ -f "$dylib" ]; then + libname=$(basename $dylib) + install_name_tool -change "@rpath/$libname" "$out/lib/$libname" "$binary" 2>/dev/null || true + fi + done fi done - '' - + ''; + + inherit (common) meta; +} From a6cdaace5b035397147ac87082409b0c9f2cf02d Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 28 Jan 2026 17:29:30 -0500 Subject: [PATCH 2/2] ensure it works on macos also --- nix/bin.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/bin.nix b/nix/bin.nix index 6ac2eeb..d22496d 100644 --- a/nix/bin.nix +++ b/nix/bin.nix @@ -16,8 +16,8 @@ pkgs.stdenvNoCC.mkDerivation { # Clear LD_LIBRARY_PATH to prevent external Qt installations from interfering qtWrapperArgs = [ "--unset LD_LIBRARY_PATH" ]; - # autoPatchelfHook uses buildInputs to find libraries (zstd, Qt, etc.) - buildInputs = pkgs.lib.optionals pkgs.stdenv.isLinux common.buildInputs; + # Required for autoPatchelfHook (Linux) and wrapQtAppsNoGuiHook (both platforms) + buildInputs = common.buildInputs; installPhase = '' runHook preInstall