Nix Anywhere Else: Relocatable Binaries via ELF Surgery
summary
Nix-built dynamic executables often fail on standard distros; the practical fix is live ELF surgery: use patchelf and the auto-patchelf-hook to rewrite the interpreter, inject a Nix-provided dynamic loader, and set an $ORIGIN rpath so bundled libs resolve at runtime. Example: a prebuilt Rust Google CLI and a Python interpreter with NumPy are patched to run on NixOS and Ubuntu, and bcachefs-tools are repackaged into a .deb via fpm and successfully run and format a filesystem in a POD container.
AI-written summary Β· about
chapters (13)
- 0:00Introduction
- 1:02Why NixOS struggles
- 3:09ELF basics for binaries
- 6:16Tools to inspect binaries
- 7:18Real-world binary failure
- 9:02Introducing patch ELF
- 11:49Python on NixOS pain
- 13:13Patching Python dependencies
- 15:22Surgery out with patch ELF
- 17:28Portable bcachefs tools
- 20:58Packaging for Debian
- 21:43Demo in Ubuntu container
- 23:27Summary and Q&A
