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

warn if process-compose is imported but not used #4

Closed
wants to merge 2 commits into from

Conversation

marijanp
Copy link
Collaborator

No description provided.

in
{
options = {
perSystem = mkPerSystemOption
({ config, self', inputs', pkgs, system, ... }: {
options.process-compose = mkOption {
default = warn "process-compose flake module was imported but not used" { };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roberth can corroborate; I think it is more idiomatic to initialize the top-level config to an empty attrset (#8) rather than throw a warning.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about an option for linting messages that don't warn by default?
I could add that to the debug attribute in flake-parts. That way we can figure some things out for the user without having to bother them with warnings which may or may not apply.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could try the lint options implemented in hercules-ci/flake-parts#134

Docs:

nix build github:hercules-ci/flake.parts-website --override-input flake-parts flake-parts/lint \
  && xdg-open result/options/flake-parts.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having some kind of information is neat because it makes you aware that you have something in your flake inputs you don't actually use. I chose to warn because it was the closest thing I found. Defaulting to an empty attribute-set makes it difficult to tell right away whether you use it or not in a big project. Also the warning does not make your build fail.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be happy if flake-part itself would inform me about unused modules.

@srid
Copy link
Member

srid commented Nov 22, 2023

In the current main branch, if the module is imported but not used it will throw an error, which forces the user to set process-compose = { }; under perSystem. Ref: https://github.com/nammayatri/shared-kernel/blob/1de10a8b1628dc123c0a62585c9adb3082b85a49/flake.nix#L61

I'll close this PR (as it is also quite out of date from main branch), but feel free to file a new issue with detailed request if I have misunderstood something!

@srid srid closed this Nov 22, 2023
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

Successfully merging this pull request may close these issues.

3 participants