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

idea: Group image actions under do #117

Open
kolloch opened this issue Feb 22, 2024 · 4 comments
Open

idea: Group image actions under do #117

kolloch opened this issue Feb 22, 2024 · 4 comments

Comments

@kolloch
Copy link
Contributor

kolloch commented Feb 22, 2024

I really like the idea of defining "convenience actions" on an image. Right now, though, they are mixed on the same level as unrelated attributes of a derivation.

n2c.aarch64-darwin.images.bash.result is an image produced with buildImage:

nix run .\#n2c.aarch64-darwin.images.bash.result.<tab>
.\#n2c.aarch64-darwin.images.bash.result.__ignoreNulls                .\#n2c.aarch64-darwin.images.bash.result.enableParallelChecking
.\#n2c.aarch64-darwin.images.bash.result.__structuredAttrs            .\#n2c.aarch64-darwin.images.bash.result.enableParallelInstalling
.\#n2c.aarch64-darwin.images.bash.result.all                          .\#n2c.aarch64-darwin.images.bash.result.fromImage
.\#n2c.aarch64-darwin.images.bash.result.args                         .\#n2c.aarch64-darwin.images.bash.result.imageName
...

I propose to bundle the actions under a passthrough sub attribute do, maybe further subdivided into categories:

nix run .\#someImage.do.<tab>
.\#someImage.do.copy  .\#someImage.do.run

and then

nix run .\#someImage.do.copy.to<tab>
.\#someImage.do.copy.to              .\#someImage.do.copy.toPodman
.\#someImage.do.copy.toDockerDaemon  .\#someImage.do.copy.toRegistry

Compatibility: I'd keep aliases at the old locations for now. Potentially with a deprecation warning.

What do you think?

@nlewo
Copy link
Owner

nlewo commented Feb 22, 2024

I also like this idea. This goes a step further than my initial implementation (image.copyTo*) which i implemented for testing purposes... it seems people are no longer using it only for testing purposes 😅

Do you know if this pattern is used elsewhere in the Nix community?

@kolloch
Copy link
Contributor Author

kolloch commented Feb 23, 2024

I don’t know of other similar patterns in the nix community.

@kolloch
Copy link
Contributor Author

kolloch commented Feb 28, 2024

I asked in a chat and there are some concerns using passthrough methods of derivations. The evaluation time accessing these methods apparently is significant (not verified).

in a flake module it is probably wiser to create a “do”sibling attribute next to the derivation of the image. For your API, you could do something similar but it would be a breaking change and in some contexts not feel as convenient, I think,

@kolloch
Copy link
Contributor Author

kolloch commented Feb 28, 2024

If you keep the pass through methods, collecting them under a do super attribute is still a good idea, I think

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

No branches or pull requests

2 participants