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

lib: aliased options don't provide their options via getSubOptions #355488

Open
llakala opened this issue Nov 12, 2024 · 0 comments
Open

lib: aliased options don't provide their options via getSubOptions #355488

llakala opened this issue Nov 12, 2024 · 0 comments
Labels
0.kind: bug Something is broken

Comments

@llakala
Copy link
Contributor

llakala commented Nov 12, 2024

Context

type.getSubOptions is a reliable way to access the options that a submodule provides. Here's an example of its usage within a repl environment:

nix-repl> nixosConfigurations.HOSTNAME.type.getSubOptions []
{
  _module = { ... };
  appstream = { ... };
  assertions = { ... };
  baseVars = { ... };
  boot = { ... };
  console = { ... };
  containers = { ... };
# etc, more nixos module options

nixd relies on this function for providing completions for submodules.

Example

lib provides a function mkAliasOptionModule. I personally use this within my configuration to give quick access to home-manager settings (aliasing home-manager.users.MYUSERNAME to hm. However, the buggy behavior comes from any alias, so I'll use the example of aliasing environment to env.

This alias could be created like this:

imports =
[
  ( lib.mkAliasOptionModule ["env"] ["environment"] )
];

This works, and now this would be a valid use of the option:

env.systemPackages = with pkgs; 
[
  git
]; 

The issue

When inspecting this alias via the repl, getSubOptions does not work as expected.:

nix-repl> nixosConfigurations.HOSTNAME.options.env.type.getSubOptions []
{
  _module = { ... };
}

The Nixd completions should show something like this:
image
But instead, they show this:
image

I don't believe this is a fault of Nixd, but instead a fault of mkAliasOptionModule. getSubOptions provides a unified experience in every other case, so it should be expected that it works the same for an aliased option.

Additional context

See nix-community/nixd#615 where I first brought this issue up, and was recommended to create an issue here.

Add a 👍 reaction to issues you find important.

@llakala llakala added the 0.kind: bug Something is broken label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

1 participant