I’ve written a bit about Nix and I still face moments where foundational aspects of the package system confounds and surprises me.
Recently I hit an issue that stumped me as it break some basic comprehension I had on how Nix works. I wanted to produce the build and runtime graph for the Ruby interpreter.
> nix-shell -p ruby > which ruby /nix/store/mp4rpz283gw3abvxyb4lbh4vp9pmayp2-ruby-3.3.9/bin/ruby > nix-store --query --include-outputs --graph \ $( nix-store --query --deriver $( which ruby )) error: path '/nix/store/24v9wpp393ib1gllip7ic13aycbi704g-ruby-3.3.9.drv' is not valid > ls /nix/store/24v9wpp393ib1gllip7ic13aycbi704g-ruby-3.3.9.drv ls : cannot access '/nix/store/24v9wpp393ib1gllip7ic13aycbi704g-ruby-3.3.9.drv' : No such file or directory
Huh. 🤔
I have Ruby but I don’t seem to have the derivation, 24v9wpp393ib1gllip7ic13aycbi704g , file present on my machine.
No worries, I think I can --realize it and download it from the NixOS cache.
> nix-store --realize /nix/store/24v9wpp393ib1gllip7ic13aycbi704g-ruby-3.3.9.drv don 't know how to build these paths: /nix/store/24v9wpp393ib1gllip7ic13aycbi704g-ruby-3.3.9.drv error: cannot build missing derivation ' /nix/store/24v9wpp393ib1gllip7ic13aycbi704g-ruby-3.3.9.drv '
I guess the NixOS cache doesn’t seem to have it. 🤷
This was actually perplexing me at this moment. In fact there are multiple discourse posts about it.
My mental model however of Nix though is that I must have first evaluated the derivation (drv) in order to determine the output path to even substitute. How could the NixOS cache not have it present?
... continue reading