Is it possible to convert a deb package into nix drv automatically?

I find that there is some example here:

Which means it is possible by human to convert a deb package handly, but I’m still wondering is it possible to make things automatically?

I know that it could be very hard, but I still want to figure out what the hardest part is, and if it is possible to be solved. if not, then why?


I think the unpacking and installing would be trivial to implement. Matching up dependencies is harder, but doing that semi-automatically probably isn’t too bad.

I suspect this isn’t done because most debs are available as source code as well, and you’d rather just package that for reproducibility.


Maybe GitHub - nix-community/nix-installers: Nix installers for legacy distributions (rpm & deb & pacman) [maintainer=@adisbladis] is interesting for you.


It’s possible to do it automatically, but only if you’re willing to accept an inferior result. No amount of automatic systems can get around the fact that programs expect a certain filesystem structure at runtime that just isn’t there. So the only way to do this really automatically is to make a runtime container that looks enough like the OS they were designed for that they can run. It’s generally preferred to package a program in a more native way if possible, so this kind of automated system hasn’t been pursued much.

1 Like

Experimenting with automatically converting deb packages to nix would be a perfect fit for the dream2nix framework.

In order to do this, two modules would have to be added to dream2nix:

  1. A dream2nix impure translator consuming a .deb package and extracting all required metadata. This could be implemented as a script that runs upstream apt toolchain on the given .deb to resolve all required URLs and hashes and possibly extract some other metadata.
  2. A dream2nix .deb builder consuming the previously extracted metadata and generating one or more nix derivations.

The reason these two phases are separated, is that it allows to render a lock file after the impure translation, and therefore transforming a previously impure package installation into a fully reproducible package one.

It would be interesting to see how this plays out.


This has been implemented during the summer of nix. See the example for debian-binary.


That project seems amazing! I’m trying to figure out how to use it, hoping for more document


This sounds great, but I’m unable to find anything about it in the examples or the documentation, I don’t know how I’d use it.

Nowhere in the code is a deb file ever named. The word “debian” only occurs in the changenote saying this feature was added.

@makoConstruct It hasn’t yet been ported to the module system. It might still work on the legacy branch.