Using dfx on NixOS?

Is anyone here working with dfx on NixOS?

Until dfx is open sourced we have to live with the binary that’s shipped in The problem is that it’s not a static binary, and has /lib64/ hard-coded as the ELF interpreter.

I can create a nix derivation that fixes that for dfx, so I can run dfx. But dfx has this odd habit of unpacking further such binaries to ~/.cache/dfinity/versions/0.8.1/, and that happens at runtime, so I cannot patch it.

I created a nix derivation that, at build time, extracts these binaries, fixes their ELF interpreter, and then uses DFX_CONFIG_ROOT to make dfx use these, but that environment variable doesn’t just affect where dfx looks for the path, but also where it stores the identity, so letting that point to /nix/store doesn’t work well either. Too bad there is no way to set just the cache directory.

I guess waiting for dfx to be open source will be easiest.

@jwiegley, how do you do that?

Now that the sdk repo is open source I had another look, but the whole way how dfx handles assets (tar-ballling them, then embedding the tarball in the code, and at runtime extracting the members) is quite … opaque.

Am I really the only on in the intersection of people who may want to use dfx and who may want to use nix?

1 Like

I created a repository with a rudimentary work-around, which could also be a place for a better solution:

1 Like