<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/nix-needs-relocatable-binaries-rlipayhxa" -->

---
title: Nix needs relocatable binaries | daily.dev
description: Nix and other store-based package managers hardcode absolute store paths into binaries, making them non-relocatable. Changing the store prefix invalidates...
canonical: https://daily.dev/posts/nix-needs-relocatable-binaries-rlipayhxa
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Nix needs relocatable binaries | daily.dev
og:description: Nix and other store-based package managers hardcode absolute store paths into binaries, making them non-relocatable. Changing the store prefix invalidates...
og:url: https://daily.dev/posts/nix-needs-relocatable-binaries-rlipayhxa
og:image: https://api.daily.dev/og/posts/rLIPAyhXA.png
og:image:alt: Nix needs relocatable binaries
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Nix needs relocatable binaries

**[Farid Zakaria’s Blog](https://daily.dev/sources/fzakaria)** · 5 min read · 0 upvotes · 0 comments

## Summary

Nix and other store-based package managers hardcode absolute store paths into binaries, making them non-relocatable. Changing the store prefix invalidates hashes, forcing full recompilation and preventing use of public binary caches. The author proposes using relative paths via the Linux dynamic linker's $ORIGIN variable in RUNPATH, but two kernel-level blockers remain: PT_INTERP (the program interpreter path) and shebang lines do not support $ORIGIN. Proposed solutions include patching the Linux kernel to support $ORIGIN in PT_INTERP and shebangs, wrapping binaries with a small static launcher, or using language-specific relative path features. The author advocates for a kernel patch and suggests adding a relocatable = true metadata flag to Nix derivations.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://fzakaria.com/2026/06/21/nix-needs-relocatable-binaries>

## Questions this post answers

### Why does changing the Nix store path from /nix/store to a custom location invalidate the build cache?

The store-prefix is embedded directly into each derivation and factors into its content hash, so changing the prefix produces a different hash even for an identical package. This breaks the ability to reuse precomputed binaries from substituters like cache.nixos.org, forcing a full local rebuild of the entire dependency graph, including things like GCC.

_Anyone weighing rootless or relocatable Nix setups can track this kind of packaging deep-dive on daily.dev._

### Why can't Nix use $ORIGIN in RUNPATH to make binaries relocatable?

RUNPATH can already use $ORIGIN, the Linux dynamic linker's variable meaning 'the directory containing the executable,' which would let libraries be found relative to the binary without changing hashes. The blocker is elsewhere: the PT_INTERP ELF header, which tells the kernel where to find the dynamic linker itself, and shebang lines in scripts, neither of which support $ORIGIN in the Linux kernel.

_Developers debugging Nix relocation issues can follow this kind of ELF and kernel-level analysis on daily.dev._

### What are the possible fixes for making Nix binaries fully relocatable despite the PT_INTERP kernel limitation?

Three approaches are proposed: patching the Linux kernel to support $ORIGIN in PT_INTERP and shebang lines, wrapping every binary with a small static launcher that computes its own location before invoking the dynamic linker, and using language-specific relative-path mechanisms like Python's __file__ for scripts. Patching the kernel is favored as the most direct long-term fix, and could even be tested today on NixOS.

_Engineers exploring Nix packaging tradeoffs can dig into proposals like these on daily.dev._

## Similar posts on daily.dev

- [One store, two frontends](https://daily.dev/posts/one-store-two-frontends-envwksejx) · Farid Zakaria’s Blog · 1 upvotes · 0 comments
- [Linux kernel will support $ORIGIN, sort of](https://daily.dev/posts/linux-kernel-will-support-origin-sort-of-bzag7lotz) · Farid Zakaria’s Blog · 1 upvotes · 0 comments
- [Making devenv start fast, and the whole nixpkgs with it](https://daily.dev/posts/making-devenv-start-fast-and-the-whole-nixpkgs-with-it-acjj6izku) · Lobsters · 2 upvotes · 0 comments
- [Nix privilege escalation security advisory](https://daily.dev/posts/nix-privilege-escalation-security-advisory-1nv8qiaev) · LWN.net · 0 upvotes · 0 comments
- [Hijacking ELF entry points for NixOS compatibility or WTF is wrap-buddy?](https://daily.dev/posts/hijacking-elf-entry-points-for-nixos-compatibility-or-wtf-is-wrap-buddy--scgexslvh) · Farid Zakaria’s Blog · 0 upvotes · 0 comments

---

Tags: [#linux](https://daily.dev/tags/linux)

[View this post on daily.dev](https://daily.dev/posts/nix-needs-relocatable-binaries-rlipayhxa)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Nix needs relocatable binaries","url":"https://daily.dev/posts/nix-needs-relocatable-binaries-rlipayhxa","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/nix-needs-relocatable-binaries-rlipayhxa"},"datePublished":"2026-06-21T19:21:04.181Z","dateModified":"2026-09-14T07:47:14.724Z","description":"Nix and other store-based package managers hardcode absolute store paths into binaries, making them non-relocatable. Changing the store prefix invalidates...","image":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","thumbnailUrl":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","isAccessibleForFree":true,"articleSection":"Farid Zakaria’s Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Farid Zakaria’s Blog","logo":"https://media.daily.dev/image/upload/s--YqqvRt90--/f_auto/v1723789280/logos/fzakaria","url":"https://daily.dev/sources/fzakaria"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/nix-needs-relocatable-binaries-rlipayhxa","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"linux","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Farid Zakaria’s Blog","item":"https://daily.dev/sources/fzakaria"},{"@type":"ListItem","position":3,"name":"Nix needs relocatable binaries"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/nix-needs-relocatable-binaries-rlipayhxa#faq","mainEntity":[{"@type":"Question","name":"Why does changing the Nix store path from /nix/store to a custom location invalidate the build cache?","acceptedAnswer":{"@type":"Answer","text":"The store-prefix is embedded directly into each derivation and factors into its content hash, so changing the prefix produces a different hash even for an identical package. This breaks the ability to reuse precomputed binaries from substituters like cache.nixos.org, forcing a full local rebuild of the entire dependency graph, including things like GCC. Anyone weighing rootless or relocatable Nix setups can track this kind of packaging deep-dive on daily.dev."}},{"@type":"Question","name":"Why can't Nix use $ORIGIN in RUNPATH to make binaries relocatable?","acceptedAnswer":{"@type":"Answer","text":"RUNPATH can already use $ORIGIN, the Linux dynamic linker's variable meaning 'the directory containing the executable,' which would let libraries be found relative to the binary without changing hashes. The blocker is elsewhere: the PT_INTERP ELF header, which tells the kernel where to find the dynamic linker itself, and shebang lines in scripts, neither of which support $ORIGIN in the Linux kernel. Developers debugging Nix relocation issues can follow this kind of ELF and kernel-level analysis on daily.dev."}},{"@type":"Question","name":"What are the possible fixes for making Nix binaries fully relocatable despite the PT_INTERP kernel limitation?","acceptedAnswer":{"@type":"Answer","text":"Three approaches are proposed: patching the Linux kernel to support $ORIGIN in PT_INTERP and shebang lines, wrapping every binary with a small static launcher that computes its own location before invoking the dynamic linker, and using language-specific relative-path mechanisms like Python's __file__ for scripts. Patching the kernel is favored as the most direct long-term fix, and could even be tested today on NixOS. Engineers exploring Nix packaging tradeoffs can dig into proposals like these on daily.dev."}}]}
```

