feat(inputs): add support for attribute representation#27
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for attribute representation to flake reference inputs, allowing users to specify inputs using individual attribute options instead of just URL-like syntax. The change enhances the flexibility of input configuration by providing granular control over flake reference attributes.
- Adds 10 new option attributes for flake references (type, owner, repo, path, id, dir, narHash, rev, ref, host)
- Removes trailing whitespace from the module
| type = lib.types.str; | ||
| }; | ||
| type = lib.mkOption { | ||
| description = "type of flake reference"; |
There was a problem hiding this comment.
The description for 'type' option is too generic. Consider being more specific about what types are valid (e.g., 'git', 'github', 'gitlab', 'sourcehut', 'path', etc.) to help users understand the expected values.
| description = "type of flake reference"; | |
| description = "Type of flake reference. Valid values: 'git', 'github', 'gitlab', 'sourcehut', 'path', etc."; |
There was a problem hiding this comment.
I could use an enum instead of a str value here, what do you think @vic?
There was a problem hiding this comment.
Yep, using an enum is better since the valid values of type is limited and not an open ended value.
Something even better would be to make sure that other attributes make sense if type is specified. eg, if type is specified then url makes no sense? and only some of the attributes are valid for each corresponding type, right?
There was a problem hiding this comment.
if
typeis specified thenurlmakes no sense?
They can be used in conjunction, for example, if type is git or file.
and only some of the attributes are valid for each corresponding type, right?
Yeah, path is only for path type. owner and repo only work in git forges types, etc.
Though, implementing this validation would be kinda tricky. But I'll try.
| type = lib.types.str; | ||
| }; | ||
| id = lib.mkOption { | ||
| description = "flake registry id"; |
There was a problem hiding this comment.
The description 'flake registry id' could be clearer. Consider expanding it to 'identifier for flake registry entries' or similar to better explain its purpose.
| description = "flake registry id"; | |
| description = "Identifier for flake registry entries"; |
| type = lib.types.str; | ||
| }; | ||
| narHash = lib.mkOption { | ||
| description = "NAR hash of the flake"; |
There was a problem hiding this comment.
Consider expanding the NAR hash description to include the format or purpose, such as 'NAR hash of the flake for integrity verification' to help users understand when and why this would be used.
| description = "NAR hash of the flake"; | |
| description = "NAR hash of the flake (e.g., 'sha256-...'), used for integrity verification to ensure the flake's contents have not been tampered with."; |
Adds support for all flake reference attributes to the flake-file.inputs option. This allows users to specify inputs using the attribute set representation, in addition to the URL-like syntax.
|
@HeitorAugustoLN I'm merging this. Thank you! |
Adds support for all flake reference attributes to the flake-file.inputs option. This allows users to specify inputs using the attribute set representation, in addition to the URL-like syntax.