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

Fix typo in manual about options without defaults #25934

Merged
merged 1 commit into from
May 21, 2017

Conversation

nh2
Copy link
Contributor

@nh2 nh2 commented May 20, 2017

Motivation for this change

Manual seems to have this the wrong way

@mention-bot
Copy link

@nh2, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ericsagnes, @grahamc and @thatdocslady to be potential reviewers.

@joachifm
Copy link
Contributor

joachifm commented May 20, 2017

I can only guess at the author's intentions here, but I read "used" as meaning "declared": failing to declare a value for an option that has no default results in eval failure.

With the proposed change, it reads more like you'll get an error if you refer to an option that has no default.

@nh2
Copy link
Contributor Author

nh2 commented May 20, 2017

@joachifm OK, let me first understand what really happens.

For terminology, from the manual:

Thus a module can declare options that can be used by other modules, and conversely can define options provided by other modules in its own implementation.

So declare means to mkOption, and define means to set that option to something, right?

Do I understand correctly that if you declare an option without default, but don't define it to have a certain value, and then some code evaluates the option from config, that is when you get an error?

Or is the behaviour that it fails independent of whether some code evaluates the option?

CC @thatdocslady from the original wording.

@joachifm
Copy link
Contributor

@nh2 Yes, that makes sense to me. I should have said "define" in my previous comment, to be consistent with the manual.

@joachifm
Copy link
Contributor

I think it'd be an improvement to change the wording to some variation of "define" rather than "use". I agree it's unclear as written.

@nh2
Copy link
Contributor Author

nh2 commented May 20, 2017

@joachifm I've just built an example of what error message nix produces when this happens:

error: The option `bla' is used but not defined.

I've also tested what happens when you declare an option without default, but don't set (define) it and don't use (evaluate) it anywhere: In that case, it runs through without complaining.

Should I change the wording to e.g.

value is used (evaluated) anywhere, an error will be thrown.

?

@joachifm
Copy link
Contributor

Ah, juxtaposing the manual with the error message makes it clearer why it is worded that way. Taken on its own, I'm not so sure, though. Nix is supposed to be non-strict & it's reasonable to expect similar behavior from its module system, so I think the caveat "if x is evaluated/used" is redundant. I'd say something like "failing to define an option that lacks a default value is an error". When phrased that way it seems kind of self evident, however, suggesting it could be removed outright ...

Anyway, I don't have strong feelings about this; if you find the manual helpful the way it is, then your clarification of what "use" means seems like an improvement to me.

@joachifm
Copy link
Contributor

joachifm commented May 20, 2017

Also, you're absolutely right that it's a typo, so we can ofc merge this as is.

@nh2
Copy link
Contributor Author

nh2 commented May 20, 2017

Nix is supposed to be non-strict & it's reasonable to expect similar behavior from its module system, so I think the caveat "if x is evaluated/used" is redundant.

@joachifm Good point. Here's another attempt for maximum clarity:

A default is not required; but if a default is not given, then
users of the module will have to define the value of the
option, otherwise an error will be thrown.

@joachifm
Copy link
Contributor

@nh2 makes sense to me :) Perhaps I'm the only one, but the use of "use" really confused me here, so for me this is much better.

@nh2 nh2 force-pushed the nixos-manual-module-option-never-fix branch from bf68043 to aed1986 Compare May 20, 2017 15:05
@nh2
Copy link
Contributor Author

nh2 commented May 20, 2017

PR updated.

@Mic92 Mic92 merged commit f279508 into NixOS:master May 21, 2017
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.

None yet

4 participants