Glistix / glistix

Fork of the Gleam compiler providing a Nix backend, compiling Gleam to Nix
Apache License 2.0
35 stars 1 forks source link

Generate Gleam types from nixpkgs? #7

Open evelant opened 3 weeks ago

evelant commented 3 weeks ago

This may be a naive question, but might it be possible to generate Gleam types for the entire nixpkgs package set and nixos/home-manager/nix-darwin option set? That could be a "killer" feature, having type checking and autocomplete for nixpkgs and options. Obviously the result would be pretty large but if it could be generated automatically on a regular basis I think it would probably work fine as package names and options don't usually change very fast after they're defined in nixpkgs.

evelant commented 3 weeks ago

Given that documentation for nixos/home-manager/nix-darwin/nixpkgs gets generated from their respective nix sources it seems this would probably be possible. I'm just not sure how feasible it is.

edit: could probably adapt something like this https://gitlab.com/rycee/nmd/ or the nixos make-options-doc https://github.com/NixOS/nixpkgs/blob/master/nixos/lib/make-options-doc/default.nix

PgBiel commented 3 weeks ago

Yup! This is definitely something I want to make possible. Open to any suggestions and/or contributions here.

Thanks for the links! Will be taking a look as well.

evelant commented 3 weeks ago

A quick look at make-options-doc and I see that it can already output JSON. Depending on what sort of type information can be extracted from that it might be fairly straightforward!