# Nix derivation madness

**URL:** https://discourse.nixos.org/t/nix-derivation-madness/71501
**Category:** Links
**Created:** [October 30, 2025, 4:25am UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501 "2025-10-30T04:25:15Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![fzakaria](https://discourse.nixos.org/user_avatar/discourse.nixos.org/fzakaria/32/2643_2.png) [@fzakaria](https://discourse.nixos.org/u/fzakaria)
#### Post date: [October 30, 2025, 4:25am UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/1 "2025-10-30T04:25:16Z")

</div>

> **[Nix derivation madness](https://fzakaria.com/2025/10/29/nix-derivation-madness)**
>
> I’ve written a bit about Nix and I still face moments where foundational aspects of the package system confounds and surprises me.

---

<div class="post-metadata">

### Author: ![clhodapp](https://discourse.nixos.org/user_avatar/discourse.nixos.org/clhodapp/32/6865_2.png) [@clhodapp](https://discourse.nixos.org/u/clhodapp)
#### Post date: [October 30, 2025, 7:39am UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/2 "2025-10-30T07:39:50Z")

</div>

This behavior has always felt sketchy to me because there’s no evidence that the “recipe” of the derivation even really produces the fixed output.

It’s always felt like each derivation referencing the output should need to get built _somewhere_ and at least a signed “note” added to the store that this derivation really does produce this fixed output.

---

<div class="post-metadata">

### Author: ![vcunat](https://discourse.nixos.org/user_avatar/discourse.nixos.org/vcunat/32/11_2.png) [@vcunat](https://discourse.nixos.org/u/vcunat)
#### Post date: [October 30, 2025, 11:16am UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/3 "2025-10-30T11:16:07Z")

</div>

You seem to be thinking more like [CA derivations](https://nixos.wiki/wiki/Ca-derivations) than the usual FOD.

---

<div class="post-metadata">

### Author: ![waffle8946](https://discourse.nixos.org/user_avatar/discourse.nixos.org/waffle8946/32/27221_2.png) [@waffle8946](https://discourse.nixos.org/u/waffle8946)
#### Post date: [October 30, 2025, 1:28pm UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/4 "2025-10-30T13:28:30Z")

</div>

> The amount of churn that we are creating in derivations was unbeknownst to me.

It’s not really “churn” - if the derivation _must_ change because the inputs changed?

I still don’t understand why the output path is the same, ~~but I didn’t actually read the whole nix thesis~~. Actually, I guess it makes sense since the path is output-addressed.

---

<div class="post-metadata">

### Author: ![fzakaria](https://discourse.nixos.org/user_avatar/discourse.nixos.org/fzakaria/32/2643_2.png) [@fzakaria](https://discourse.nixos.org/u/fzakaria)
#### Post date: [October 30, 2025, 1:42pm UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/5 "2025-10-30T13:42:57Z")

</div>

This part can be expanded is I suspect there’s no reason why the path for the derivation itself can’t be modulo either I think.

Right now it’s a CA style calculation but it’s confusing have so many now…

---

<div class="post-metadata">

### Author: ![drupol](https://discourse.nixos.org/user_avatar/discourse.nixos.org/drupol/32/9471_2.png) [@drupol](https://discourse.nixos.org/u/drupol)
#### Post date: [October 30, 2025, 3:14pm UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/6 "2025-10-30T15:14:23Z")

</div>

Interesting ! Thanks for the post and for the discovery of the word `unbeknownst` ! 🙂

---

<div class="post-metadata">

### Author: ![waffle8946](https://discourse.nixos.org/user_avatar/discourse.nixos.org/waffle8946/32/27221_2.png) [@waffle8946](https://discourse.nixos.org/u/waffle8946)
#### Post date: [October 30, 2025, 3:29pm UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/7 "2025-10-30T15:29:29Z")

</div>

> [@fzakaria](#):
>
> This part can be expanded is I suspect there’s no reason why the path for the derivation itself can’t be modulo either I think.

How could the drv be the same? The contents _are_ different. It’s not like the store path itself which just cares about `outputHash` (and `name`).

---

<div class="post-metadata">

### Author: ![fzakaria](https://discourse.nixos.org/user_avatar/discourse.nixos.org/fzakaria/32/2643_2.png) [@fzakaria](https://discourse.nixos.org/u/fzakaria)
#### Post date: [October 30, 2025, 3:40pm UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/8 "2025-10-30T15:40:43Z")

</div>

The calculation does not have to be content addressable for the drv path.  
It can also be modulo the fixed-output-derivations as well I think.

---

<div class="post-metadata">

### Author: ![waffle8946](https://discourse.nixos.org/user_avatar/discourse.nixos.org/waffle8946/32/27221_2.png) [@waffle8946](https://discourse.nixos.org/u/waffle8946)
#### Post date: [October 30, 2025, 3:45pm UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/9 "2025-10-30T15:45:38Z")

</div>

I don’t understand, can you say that in simpler terms without using “modulo”?  
I still don’t understand why a file with different contents should have the same path (in your view).

---

<div class="post-metadata">

### Author: ![fzakaria](https://discourse.nixos.org/user_avatar/discourse.nixos.org/fzakaria/32/2643_2.png) [@fzakaria](https://discourse.nixos.org/u/fzakaria)
#### Post date: [October 30, 2025, 9:05pm UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/10 "2025-10-30T21:05:12Z")

</div>

I feel your pain with “modulo” – you should read the academic draft @Ericson2314 put up.  
😸

When calculating the outPath for a derivation we already replace out FOD with their outPath in the drv so that the path doesn’t change needlessly. (This is what gives FOD super powers for not doing mass rebuilds).

For all other inputs to a derivation the `.drv` path is used in the calculation of the outPath.

Now the thing I wanted to highlight, is that `.drv` themselves have an outPath.  
(The path of the .drv file itself not the produced artifact)

This path is usually calculated as a content-addressed hash so it changes depending on all inputs which I tried to demonstrate in my blog. This causes a lot of drv “churn”.

I was contemplating, could we not also replace the inputDrvs when calculating the store path of the `.drv` file itself also to avoid churn.  
(I suspect yes)

---

<div class="post-metadata">

### Author: ![fzakaria](https://discourse.nixos.org/user_avatar/discourse.nixos.org/fzakaria/32/2643_2.png) [@fzakaria](https://discourse.nixos.org/u/fzakaria)
#### Post date: [October 31, 2025, 2:37am UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/11 "2025-10-31T02:37:17Z")

</div>

I added a new graph to the blog to help (I hope – feedback welcome)

 ![image](https://discourse.nixos.org/uploads/default/original/3X/4/5/45e68b83cb1288f520941316b06ad319132769af.png)

---

<div class="post-metadata">

### Author: ![clhodapp](https://discourse.nixos.org/user_avatar/discourse.nixos.org/clhodapp/32/6865_2.png) [@clhodapp](https://discourse.nixos.org/u/clhodapp)
#### Post date: [October 31, 2025, 4:28pm UTC](https://discourse.nixos.org/t/nix-derivation-madness/71501/12 "2025-10-31T16:28:28Z")

</div>

Yes! Almost like a weaker form of CA derivations in terms of the exposed interface (but the details of the build process would be pretty different).
