From de061dd598c32448fd752aae79234e1a180ccac0 Mon Sep 17 00:00:00 2001 From: Moshi Binyamini Date: Tue, 19 May 2026 13:00:32 -0400 Subject: [PATCH] fix: set portable interpreter path in Nix build Release binaries built with Nix have hardcoded Nix store paths for the dynamic linker, causing them to fail on non-Nix Linux systems with "No such file or directory" error. This fix adds patchelf to the Nix build process for cross-compilation packages (x86_64-linux and aarch64-linux) to set the interpreter path to standard system locations during the installPhase: - /lib64/ld-linux-x86-64.so.2 for x86_64 - /lib/ld-linux-aarch64.so.1 for aarch64 This approach is cleaner than adding patchelf as a CI dependency since patchelf is already available in nixpkgs and the fix is applied at build time rather than as a post-processing step. Fixes #15 Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- flake.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flake.nix b/flake.nix index a91014c..5f5b3e3 100644 --- a/flake.nix +++ b/flake.nix @@ -96,6 +96,7 @@ nativeBuildInputs = with pkgs; [ gcc gnumake + patchelf ]; buildPhase = '' @@ -105,6 +106,8 @@ installPhase = '' mkdir -p $out/bin cp dist/try $out/bin/ + # Set portable interpreter path for non-Nix systems + patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 $out/bin/try ''; meta = with pkgs.lib; { @@ -125,6 +128,7 @@ nativeBuildInputs = with pkgs.pkgsCross.aarch64-multiplatform; [ gcc gnumake + patchelf ]; buildPhase = '' @@ -134,6 +138,8 @@ installPhase = '' mkdir -p $out/bin cp dist/try $out/bin/ + # Set portable interpreter path for non-Nix systems + patchelf --set-interpreter /lib/ld-linux-aarch64.so.1 $out/bin/try ''; meta = with pkgs.lib; {