dhall-lang/dhall-nix

Dhall types for higher-level nix concepts?

jwoudenberg opened this issue · 3 comments

First of, thanks for creating this library and the Dhall language in general! I've been having fun using Dhall for templating and generating JSON and recently started looking into using it to help me learn Nix as well.

I was wondering if there exist any Dhall modules exposing types of higher-level Nix-concepts, like derivations, and functions mirroring some of the standard functions exposed by nixpkgs.

Some context: I'm a beginner Nix-user and regularly get stuck when I accidentally pass the wrong 'type' of nix structure to a function in nixpkgs. Usually it takes a while for me to figure out what's going wrong based on the often cryptic (for me) error nix gives me. I'd love to use typed versions of these functions that provide nicer errors, I think that would improve my experience of learning nix a lot.

My sense from reading the documentation of dhall-nix is that it requires its users to know what the underlying record representation of nix-concepts like derivations, which isn't how I usually see nix thought in official documentation and blogs. Would it be fair to say that dhall-nix is at the moment mostly aimed to the experienced Nix user looking for typing support for maintaining complicated nix expressions, less so the beginning Nix user looking for types to guide their learning? Or am I way off base here?

I'm not aware of such a library

dhall-nix was mostly a proof-of-concept showing one possible way to make Nix typed but a lot of Nixpkgs idioms don't map well onto Dhall types. That's not to say that the mismatch can't be fixed (since dhall-json has several features to support weakly-typed JSON idioms) but I haven't gotten any requests to do so, yet.

The closest thing I'm aware of actually bypasses the Nix language and uses Dhall to directly generation .drv files: https://github.com/ocharles/dhall-build

Thank you for the response and the link, appreciate it! Closing this issue as it was more of a question than anything else.

You're welcome! 🙂