Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for annotating types. #87

Open
ehllie opened this issue Jun 3, 2023 · 2 comments
Open

Allow for annotating types. #87

ehllie opened this issue Jun 3, 2023 · 2 comments
Labels
A-ty Area: type system C-feature Catagory: feature

Comments

@ehllie
Copy link

ehllie commented Jun 3, 2023

I've noticed that in recent versions of nil, there is now inference for attributes inside module arguments like config:
image

It's definitely very convenient when writing NixOS modules, but they don't exactly align with the the config options when writing something like a home-manager or nix-darwin module. Trying to dynamically infer it might be possible, but I think it might be more difficult, and not always possible. That's why I suggest an introduction of a type comment syntax/system for annotating these things manually. That way one could write something along the lines of:

# @type home-manager.module
{ config, pkgs, ... }:
{
...
}

This would obviously not be a small feature, since it would probably require a syntax for defining types, and also a method for flakes to export them, but in my opinion it would be a very useful feature.

@bew
Copy link

bew commented Jun 3, 2023

Might be related: Since NixOS/nixpkgs#197547 evalModules function has a class parameter which can be used to give a type to modules.

@oxalica oxalica added C-feature Catagory: feature A-ty Area: type system labels Jun 4, 2023
@oxalica
Copy link
Owner

oxalica commented Jun 4, 2023

but they don't exactly align with the the config options when writing something like a home-manager or nix-darwin module.

Currently NixOS options are extracted using a handcrafted Nix here and it's coupling with nixpkgs. I'm not sure if we could somehow extract options from the home-manager module in a similar way.

Might be related: Since NixOS/nixpkgs#197547 evalModules function has a class parameter which can be used to give a type to modules.

It is just a string identifier. It cannot help with types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty Area: type system C-feature Catagory: feature
Projects
None yet
Development

No branches or pull requests

3 participants