Nix can't import `.drv` files and it limits interoperability with other languages that use the Nix store

Nix language and .drv files are technically separate. I could write a new language that generates valid .drv files and build them with nix-store --realise.

However, the Nix language has no primitive (like readDerivationFromFile or importDrv) to import those .drv files into Nix expressions. This means:

  • :white_check_mark: Alternative language → .drv → builds successfully

  • :cross_mark: Composing that .drv with Nix packages

The Nix language can only compose derivations created by Nix itself.

Is this an intentional design choice? Are there technical reasons, or has anyone found workarounds?

1 Like

Have you tried calling import on a drv file?

6 Likes

Ah… it works. Thanks!