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

Add an attribute that can be used to label custom attributes in nix flake show #6454

Open
NobbZ opened this issue Apr 27, 2022 · 2 comments
Open
Labels

Comments

@NobbZ
Copy link
Contributor

NobbZ commented Apr 27, 2022

Is your feature request related to a problem? Please describe.

In a common flake there are some custom attributes used, that appear in nix flake show just as "unknown". One of the commonly used custom attributes is lib (used by nixpkgs itself). Also homeConfigurations and homeModules are rather common since home-manager got flake support. And I am sure there are equivalent attributes for nix-darwin.

Describe the solution you'd like

There should be a way to label these. This could be done by adding an extra attribute labelers to the flake schema.

A labeler then is a function that returns either a string or an arbitrary nested set of strings. nix flake show will use each attribute name as a "node" in the tree and increase nesting, while a string value will be used as label. As far as I can tell, this would pretty much match what one sees in the nix flake show --json output.

Whenever nix flake show discovers an unknown attribute foo it will call self.labelers.foo self.foo. The labeler then has to inspect the value and build the aforementioned label tree.

The following show snippet could have been created by the returned nix value below it:

├───homeConfigurations
│   ├───nobbz@enceladeus: Home Manager configuration
│   ├───nobbz@mimas: Home Manager configuration
│   └───nobbz@thetys: Home Manager configuration
{
  "nobbz@enceladeus" = "Home Manager configuration";
  "nobbz@mimas" = "Home Manager configuration";
  "nobbz@thetys" = "Home Manager configuration";
}

Describe alternatives you've considered

External programs that are required to increase discoverability of custom attributes

@fricklerhandwerk
Copy link
Contributor

fricklerhandwerk commented Nov 30, 2022

Triaged in Nix team meeting on 2022-11-25:

  • @edolstra: not in favor of adding ad hoc hacks like this
    • should have something like a module system instead, describing properties of flakes
      • this is of course a long-term thing
    • better not pollute flakes with ad-hoc stop-gaps, that would prevent solid long-term solutions

-> to discuss

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2022-11-25-nix-team-meeting-minutes-11/23601/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants